refactor user registration