removed multiple .length calls