refactored websocket api