
    ZURN INDUSTRIES, INC., Plaintiff-Third Party Plaintiff-Appellant, v. ACTON CONSTRUCTION CO., INC., Defendant-Appellee, v. CITY OF GARLAND, A Texas Corp., Defendant-Counter Plaintiff-Appellant, v. URS CO., Successor in Interest of Forrest & Cotton, Inc., A Texas Corp., Defendant-Counter Defendant-Appellant. BROYLES & BROYLES, et al., Counter Defendants-Appellees, v. ICI AMERICAS, INC., Third Party Defendant-Appellee-Appellant.
    No. 87-1441.
    United States Court of Appeals, Fifth Circuit.
    June 17, 1988.
    
      Neal J. Sweeney, Bert R. Oastler, Atlanta, Ga., for City.
    John C. McIntyre, Thomas J. Wingfield, III, Carolyn Thom Thurston, Atlanta, Ga., for Zum.
    Jay A. Brandt, Joe B. Harrison, Michael G. Wimer, Dallas, Tex., for ICI Americas.
    Willis E. Kuhn, II, Raymond V. Carroll, Jr., David Taubenfeld, William Allens-worth, Dallas, Tex., for URS.
    G. Luke Ashley, Katherine Armstrong, Dallas, Tex., for Broyles & Broyles, Inc.
    Joe F. Canterbury, Jr., Dallas, Tex., for Acton Const. Co.
    James Gregory Marks, R. Brent Cooper, Dallas, Tex., for Engineering Science, Inc.
    Before REAVLEY, GARWOOD and DAVIS, Circuit Judges.
   REAVLEY, Circuit Judge:

Zum Industries, Inc., appeals the district court’s dismissal for lack of subject matter jurisdiction after the court realigned the parties at the expense of diversity. We conclude that the realignment was improper and reverse and remand.

I.

The controversy arises out of the construction of Garland, Texas’s Duck Creek Sewage Treatment Plant. Zum was the subcontractor who built the carbon absorption system, one component of the project. Acton Construction Company was one of the two general contractors. URS Company was the design engineer for the whole project.

Shortly after the new plant started up, the underdrains on the carbon absorption unit ruptured. Zum then attempted to repair and modify the underdrains. After considerable work, Zurn abandoned the effort. Eventually, the unit was repaired and included in a system that was different than the originally designed plant.

The court action began in 1982 when Garland, a Texas citizen, filed suit against URS Co., also a Texas citizen, in state court. That suit alleged that URS’s novel physical/chemical process design could have never produced the required effluent quality. Garland alleged damages of over $20,000,000.

Zum, a Pennsylvania citizen, then brought this suit against Garland, URS, and Acton, a Minnesota citizen. Zum sought approximately $900,000 for the extra work in the attempted repair of the underdrain. Zum alleged that URS’s design error, or Garland’s operational error, caused the underdrain to rupture. The action against Acton was based on contract.

Garland then added Zum, Acton and others to the state court claim of process design failure. Garland also cross-claimed and counterclaimed in Zum’s federal suit on the same process design allegation. Additionally, Garland cross-claimed and counterclaimed seeking some $5,000,000 on the theory that the underdrain was negligently designed or built. Various other cross-claims and counterclaims were filed and additional parties added. All parties then voluntarily agreed to a non-suit in state court and to pursue their differences in federal court.

The district court sorted through all the various claims and stated that there were two “primary” claims: (1) the process design claim, or whether the design could have ever worked, and (2) the underdrain claim, or whether the underdrain was properly constructed. The district court decided, and all parties agree, that Garland was the plaintiff on the process design claim. The court also decided that Garland was the “real plaintiff in interest” on the under-drain claim. Using City of Indianapolis v. Chase Nat’l Bank, 314 U.S. 63, 62 S.Ct. 15, 86 L.Ed. 47 (1941), the court then realigned Garland as the plaintiff on the underdrain claim. The realignment put Texas citizens on both sides of the suit — Garland as plaintiff, URS as defendant — and diversity jurisdiction was destroyed. The court then dismissed the entire case for lack of subject matter jurisdiction.

II.

A.

As a general rule, diversity of citizenship is determined at the commencement of a lawsuit. Carlton v. BAWW, Inc., 751 F.2d 781, 785 (5th Cir.1985). Subsequent events, such as a change in citizenship or the amount in controversy falling below $10,000, will not divest the court of subject matter jurisdiction. Id.

One exception to the general rule is the realignment of parties. See City of Indianapolis, 314 U.S. 63, 62 S.Ct. 15, 86 L.Ed. 47. In City of Indianapolis, Chase, a New York corporation, sued Indianapolis Gas Co., Citizens Gas Co., and the City of Indianapolis, all Indiana residents. Id. at 68, 62 S.Ct. at 16. The Court explained that there must be an actual, substantial controversy between citizens of different states to sustain diversity jurisdiction. Id. at 69, 62 S.Ct. at 17. To do that, a court must “look beyond the pleadings, and arrange the parties according to their sides in the dispute.” Id. (quotation omitted). The “necessary ‘collision of interest’ ” has to be determined “from the ‘principal purpose of the suit,’ and the ‘primary and controlling matter in dispute.' ” Id. (citations omitted). In City of Indianapolis itself, the Court found that the principal matter in dispute was whether a lease was valid. Id. at 71, 62 S.Ct. at 18. Since both Chase and Indianapolis Gas wanted the lease enforced, Indianapolis Gas was realigned as a plaintiff with Chase. Id. at 74, 62 S.Ct. at 19. Therefore, citizens of Indiana were on both sides of the dispute and there was no diversity jurisdiction. Id. The Fifth Circuit has consistently followed the principles of City of Indianapolis. See Lowe v. Ingalls Shipbuilding, A Div. of Litton Sys., Inc., 723 F.2d 1173, 1177-78 (5th Cir.1984) (named defendant Owens-Coming had no dispute with plaintiffs and, therefore, Owens-Corning realigned as plaintiff resulting in Delaware citizens on both sides); Indemnity Ins. Co. v. First Nat’l Bank at Winter Park, Fla., 351 F.2d 519, 522-23 (5th Cir.1965) (no bona fide dispute between Indemnity and Winter Park Bank, resulting in realignment and no diversity).

? subject matter jurisdiction is proper, the court may have ancillary jurisdiction over additional claims or parties that it may not have had otherwise. Whether the court has ancillary jurisdiction over the claim or party depends on the type of claim or party. If the claim is a compulsory counterclaim, Fed.R.Civ.P. 13(a), a cross-claim, Fed.R.Civ.P. 13(g), or if the party is added pursuant to a counterclaim or cross-claim, Fed.R.Civ.P. 13(h), or im-pleaded, Fed.R.Civ.P. 14, the court has an-ciliary jurisdiction over the claim or party even in the absence of an independent basis for federal jurisdiction. See Plant v. Blazer Fin. Serv’s., Inc. of Ga., 598 F.2d 1357, 1359 (5th Cir.1979) (ancillary jurisdiction over compulsory counterclaim); Amco Constr. Co. v. Miss. State Bldg. Comm’n, 602 F.2d 730, 732 (5th Cir.1979) (ancillary jurisdiction if proper cross-claim); H.L. Peterson Co. v. Applewhite, 383 F.2d 430, 433 (5th Cir.1967) (ancillary jurisdiction over party brought in pursuant to compulsory counterclaim or brought in under Rule 14); see generally, 13 C. Wright, A. Miller & E. Cooper, Federal Practice and Procedure: Jurisdiction 2d § 3523 at 106-12 (West 1984) (hereinafter 13 C. Wright). However, if the counterclaim is only a permissive counterclaim, Fed.R.Civ.P. 13(b), or if the party is brought in pursuant to Fed. R.Giv.P. 19 or 20, there is no ancillary jurisdiction and there must be an independent ground for federal jurisdiction. See Plant, 598 F.2d at 1359 (permissive counterclaim); Lowe, 723 F.2d at 1177 (Rules 19 & 20); see generally, 13 C. Wright § 3523 at 106-15. Although, usually, the absence of federal jurisdiction over the permissive counterclaim or party brought in under Rule 19 or 20 will result only in the dismissal of that claim or party, there are situations where the additional claim or party may result in complete dismissal. If the case cannot continue with the added party or if the amendment of the pleadings alters the nature of the action, jurisdiction must be reassessed at that time. Carlton, 751 F.2d at 785. For example, if a plaintiff in a diversity case adds a claim against a third party defendant who is not diverse, then subject matter jurisdiction is destroyed. Owen Equip. & Erection Co. v. Kroger, 437 U.S. 365, 98 S.Ct. 2396, 57 L.Ed.2d 274 (1978).

B.

The district court realigned the parties according to what it viewed as the two “primary” claims. The court took all of the various claims including the counterclaims and cross-claims and determined which two were the “primary” claims. Joining of all the claims and deciding which are the “primary” claims is not warranted by City of Indianapolis. The objective of City of Indianapolis realignment is only to insure that there is a bona fide dispute between citizens of different states. 314 U.S. at 69, 62 S.Ct. at 17. The determination of the “primary and controlling matter in dispute” does not include the cross-claims and counterclaims filed by the defendants. Instead, it is to be determined by plaintiffs principal purpose for filing its suit. In complex litigation like this case, with its various claims flying back and forth, there are two distinct steps in the jurisdiction determination. First, the court examines the primary or original purpose for filing suit. If the parties are not realigned on that claim, and there is no showing that the claim was a sham simply asserted for federal jurisdiction, subject matter jurisdiction exists. At that point, the various other claims may be examined to determine if they are properly in the court’s ancillary jurisdiction or have an independent basis for federal jurisdiction. If the added claim or party has no proper jurisdictional basis, joinder of that claim or party would not be proper. We illustrate the test by applying it to this case.

The principal claim here is Zurn’s claim for almost $900,000 for extra work. That claim continues to exist. It is a bona fide claim, as all parties admit, not just asserted to create federal jurisdiction. On that claim, none of the defendants should be realigned under City of Indianapolis. Zum has a legitimate dispute with URS, Garland and Acton. The fact that Zum is on the same side as Acton and URS on Garland’s cross-claims and counterclaims is of no consequence to the jurisdiction over the original claim.

Having determined that realignment was not proper, we determine that the addition of the other claims and parties was proper. The original claim was brought under theories of negligence and contract for additional work on the under-drains of the carbon absorption unit of the waste treatment plant. Garland counterclaimed and cross-claimed alleging that the underdrain was improperly constructed or designed and that the whole system design was improper. Those claims arose from the same transaction or occurrence as Zum’s original claim for additional work. Therefore, the cross-claim was proper, see Fed.R.Civ.P. 13(g), and the counterclaims were compulsory, see Fed.R.Civ.P. 13(a). The fact that the claims were for a greater dollar amount makes no difference in the absence of a showing that Zum’s original claim was a sham to assert federal jurisdiction. There was ancillary jurisdiction over the counterclaims and cross-claims. Plant, 598 F.2d at 1359; Amco Constr. Co., 602 F.2d at 732. There is also ancillary jurisdiction over the parties — Broyles & Broyles, Inc., Engineering Science, Inc., Travelers Indemnity Co., and United States Fidelity and Guaranty Co. — brought in as defendants to Garland’s claims. Fed.R. Civ.P. 13(h); H.L. Peterson Co., 383 F.2d at 433. Jurisdiction over the other additional parties — Zimpro, Inc,, ICI Americas, Inc., and American Automobile Ins. Co.— brought in on claims of indemnity, was also proper under ancillary jurisdiction. See Fed.R.Civ.P. 14; H.L. Peterson Co., 383 F.2d at 433. Similarly, the cross-claims and counterclaims of other parties would be under the court’s ancillary jurisdiction if it arose from the same transaction or occurrence.

The district court tried to sort out the various disputes and come up with a reasonable way to try this complex case. However, that sorting process should not include a realignment for diversity purposes. Engineering Science, the appellee, suggests that Garland, the main protagonist in the case, should be realigned as a plaintiff. They argue that Garland is the “true” plaintiff. That argument ignores the fact that Zum, as a Pennsylvania citizen, had a right to sue the various defendants, all non-Pennsylvania citizens, in federal court. The fact that the various counterclaims and cross-claims are for large dollar amounts does not alter that fact. Nor is Zum’s right affected by the fact that the case could not have been removed to federal court if Garland would have first sued the other parties. As we explained, the primary purpose of the suit, for City of Indianapolis purposes, was Zum’s $900,-000 claim for extra work. That primary purpose has not changed — it is still a bona fide dispute — and no party can be realigned with Zum on that claim. Therefore, diversity jurisdiction existed at the inception of the lawsuit and continues to exist. The various cross-claims and counterclaims, even in the absence of an independent ground for federal jurisdiction, are properly before the federal court pursuant to its ancillary jurisdiction.

REVERSED and REMANDED. 
      
      . Zurn is joined by a number of defendants in appealing the district court’s decision. Engineering Science, Inc., a third party defendant, is the only party on appeal who argues in support of the decision.
     
      
      . But if an indispensable party cannot be properly added, the whole lawsuit may be subject to dismissal. See Fed.R.Civ.P. 19(b).
     
      
      . Since there would be ancillary jurisdiction in the absence of independent federal subject matter jurisdiction, we need not examine whether diversity exists on the cross-claims and counterclaims.
      We note that, technically. Garland’s counterclaim of design defect might not fall into the provisions of Rule 13(a) since "the claim was the subject of another pending action.” However, since the claim arose out of the same transaction or occurrence, ancillary jurisdiction over it was proper. H.L. Peterson Co., 383 F.2d at 433 n. 3 (explaining the "pending action" exception as an option not precluding ancillary jurisdiction).
     
      
      . We have only examined the counterclaims and cross-claims of Garland since they are the dominant claims. We do not mean to imply that the cross-claims and counterclaims of the other parties are not covered by the court’s ancillary jurisdiction. On the contrary, those claims, too, appear to arise out of the same transaction or occurrence and ancillary jurisdiction over those claims would be proper. Of course, if the court should discover on remand that a cross-claim or counterclaim did not arise from the construction dispute, and there is no independent basis for jurisdiction, it is free to dismiss that claim.
     
      
      . Zum also appeals the grant of summary judgment in favor of ICI Americas. At the time of the district court’s dismissal, a motion was pending to reconsider that summary judgment. Since the district court never addressed the motion for reconsideration, we leave that decision, in the first instance, to the district court. Similarly, since the court could change its original decision, we decline to address the merits of the original grant of summary judgment. If the district court adheres to its original decision, Zurn is free to contest that ruling in any proper subsequent appeal.
     