Fixing handling of the if statement