refactoring user creating logic