fix bug in stop() function