could you put a 

>if(A.armor && A.armor["melee"])

check before this line?