fixed a problem with the if statements