better socket.io code