wrote functions to cache and solve matrices