Simplify for loops