covariance matrix inversion moved to separate function