Update getEnergyObject.js

Some optimizations