tweaking code to make first statements in if the most likely to break
out of if.