fixed incorrect correlation function