reorders the if statements to stop breaks on nil sooner