improvements on socket.io code