Change the way the covariance is computed to avoid problem with not positively defined covariance matrices