fixed syntax error and better handling of motion detection