Fixed bug by added the energy parameter. TODO: define the energy with a button