Refactored the motion_notify method