added support for aggregating on categories