Added code to cache inverse matrix