Added optimization for if-then-else inside a multiplication