add code to create and inverse matrix and cache it