Update getEnergyObject.js

Some optimizations
Merge pull request #1 from gekkstah/patch-1

Update getEnergyObject.js