refactored user registration