Reorganized code for Fourier