Simplify for loop