modified for socket.io