fix energy calculation