moved line out of loop