Implemented caching the inverse of matrix