Fix catastrophic backtracking issue