Rewrote the matching/search algo