refactored websocket support