improved pair extractor, to match more terms