added motion detection