implement clearing matrix