refactored registering user