rolled my own autocorrelation function