fixed bug in energy.lua