refactored a lot
whoops. didn't mean to commit that change to AggregateQuery