updated code for caching the inverse of a Matrix