extracted formatting from QueryMessages