found bugs in closing sockets