wrote cacheMatrix function