Replace each closure with for loop for optimization