Add motion detection algorithm