fixed covariance calculation