implementing Match()