updated energy calculation