Completed the function for caching matrix inverse