An if/else was added to trigger motion detection only when in motion detection mode.