made changes to the aggregation and join queries