fix for generating the start and end keys