Added motion detection