rewrote using TCPSocket