first draft of matrix inlining