reorder if statements to remove negation, indentation correction