updates to cache the matrix