Added more code to get correlated quries