included motion detection and refactor functions into their own classes