Removed assigning of elements.length to a separate variable