Added motion_detection code