if you use this macro at the beginning:

/stopmacro [noharm][dead] <--- something like that it will make sure you never accidentally (not sure if its [noharm/harm] or [nodead/dead]) wasting your cooldowns when you dont have something targetted that is alive.