first version of a matching. works fairly well, but perhaps not where we want it to be