optimized tags matching