added a function to check if the parenthesis are balanced