Was looping over 2*nfreq instead of nfreq.