Added getElementsInRange(start, end) helper function