finished writing restricted-mod-mat.