modified findCorrelation code for speed