adding balanced parentheses