Fix to checking of end and start