implemented CacheMatrix