Need help with dismount macro

Hey guys,
I’m trying to make a macro that lets me dismount and charge only when i’m in range.

/dismount
/cast charge
just dismounts me if i’m out of range. looked online and couldn’t find anything.
any help would be great! :smiley:

Alphinejuice

https://www.curseforge.com/wow/addons/leatrix-plus-classic

that addon has auto dismount and a ton of other quality of life stuff I must have.