working on conversion to linear matrix code