Fixing the stop function