added checks to cov matrix to make sure it can be inverted and not fail