simplifying the queries to get rid of the old query structures
grouping pdf generation together
removing the old query structure
simplifying queries