Edit outer loop to be more readable