moved socket.on to constructor