Fixed bug in chat query