Fixed logic for creating correlation functions