a better restarting animation and adds callback functions