translating for loops