Correct the error in free_energy calculation