Added optimizations for if-then-else in equality check