Shortened the code using TCPConnection class