Bugfix in generateSpectrum