refactored socket.io