refactored websocket