fix issue with empty results from aggregation ($unique) and $count