Fixed the function expecting column wise spectra, now gives correct answer