enroll function refactoring