corrected stop function