correlation code is finished, but do it more correctly