modified end stop check