#5 changed iteration to more efficient way