changed the stop function