New method

method based on the algorithm I wrote (energyAlgo)