improved web socket handling