revised WebSocket implementation