finding correlation using loop