Corrected Order of operation for loop