made a generalised correlation function