improving the reliability of the stop script