developed function to return and cache inverse matrix