Adding queries and logic to the long report