first draft of matrix invert cache logic