Change array.lentgh to variable in for