Fixed the pause, resume and stop functions