Refactor to handle enroll mode.