Fixing matching of parentheses