added covariance functoin