resolve the problem of nested parentheses