reversing for loop