refactor the registration flow