Help with Targeting Macro

Hi, I’m trying to make a macro that will target an enemy if I have no target or a dead target, and then cast an ability. Would the following sequence work for that? If not, please post one that will.

#showtooltip
/targetenemy [dead,noexists]
/startattack
/cast Blade of Justice

[this, and this]
[this] [or this]
; else this
#showtooltip
/targetenemy [dead] [noexists]
/cast Blade of Justice

Ok wonderful, thank you!