fixed incorrect if statements