Refactor user registration