Changed method for calc covariance matrix