have socket funtions be of type Socket
clean up socket close functionality by using waitGroup