Implement registration
Move client registration to its own function