Final code for cacheMatrix