createAggregatedMetrics funtion fixed.