fix to checking of start and end