changing looping for trend aggregation