refactored client initialization