implemented inverse matrix cache function