refactored cross correlation. fixed bug where delay index into output is out of bounds