Move correlation into separate function.