cleaned up the WebSocket code