Simplify loop code.