changed the order of an if statement