add codes to calculate correlation length