added a stop() function