Fix recursion issue with getEnergy.