caching the matrix