socket.io refactor