finally got the matching working, but had to just rewrite it my own way