refactoring
refactored client connection