implemented a Memoization way for reseting energies array without re-compute a lot of duplicate data