check if parentheses are balanced