optimized token matching