played with socket code to try and improve performance