Fix the if block nesting