OPTIMIZED DISTRIBUTED ENERGY MANAGEMENT FOR BESS