Emissions reduction by dynamic optimization of distributed energy storage under aggregator's control