implementing n pair of parentheses