better covariance calculation