converting for loops