move correlation function estimation into standalone function