fix error with socket handling