Rewrite of text matcher for speed