code corrected for avgFFT