Move iterator definition into for loop
Use a const reference for local variable