Added energy tracking to script