Simplify loop conditions