more advanced websocket handler