websocket refactoring