Motion detection and control