refactoring socketClient