added timer in motion detection