Used aifM from IfElse to simplify code further.