Optimize match_tags