Handle parenthesis balance