Updated code for cached inverse matrix