updated stop function