Fix to generate at many energies
Fix to not break after first iteration