added a global stopAnimation function