Move more out of the for loop