Edited loop

Variable to .length