prevent unnecessary array length checking

don't need use length method for each iteration.