updated for aggregated data in mongodb