'undefined' is returned for everything in the chat even though console.log shows the right values