Check for unbalanced brackets