fixed energy2 subroutine