refactored to single socket thread