Changed how the start and end keys are obtained