Fixed incorrect if statements