Change the method to calculate the energy