websocket refactor