improved query pretty printer