another try to fix catastrophic backtracking