optimizing energy storage