Pull out query/data parts of report generation