Fix bug: calling the motion callback more than once