Rearranged for loops