little chage to loop

change the loop so it doesn't have to look up the length each time