optimized the algorithm for motion detection to be 50% faster.