Finish the cache matrix function