finished implementation and detect moving object