fixed a faulty if statement