fixed the energy calcutations