added cov matrix funtion