started writing matrix inlining logic