edited for loop

Edited for loop, added .length