Modified to use socket.io