moved functions
handle aggregation in queryBuilder