refactor registration process