
    PROGRESSIVE CONSUMERS FEDERAL CREDIT UNION, Plaintiff, Appellant, v. UNITED STATES of America, Defendant, Appellee.
    No. 95-1712.
    United States Court of Appeals, First Circuit.
    Heard Nov. 7, 1995.
    Decided March 19, 1996.
    
      Stephen M. Sheehy, with whom Kaye, Fialkow, Richmond & Rothstein were on brief, Boston, MA, for appehant.
    Kevin M. Brown, with whom Donald K. Stern, United States Attorney, Boston, MA, Loretta C. Argrett, Assistant Attorney General, Gary R. Allen, and William S. Esta-brook, Tax Division, Department of Justice, were on brief, Washington, DC, for appellee.
    
      Before BOUDIN, Circuit Judge, BOWNES, Senior Circuit Judge, and STAHL, Circuit Judge.
   BOWNES, Senior Circuit Judge.

On October 8,1993, Progressive Consumer Federal Credit Union (“Progressive”), plaintiff-appellant, filed a complaint against the Internal Revenue Service (“the government”), defendant-appellee, in the Land Court Department of the Trial Court of Plymouth County, Commonwealth of Massachusetts. Progressive sought a declaration that its mortgage had priority over properly recorded federal tax liens. The government filed a notice of removal pursuant to 28 U.S.C. § 1444, removing the action to the United States District Court for the District of Massachusetts. The district court entered a memorandum and order granting the cross-motion of the United States for summary judgment oh May 26,1995, holding that Progressive’s mortgage was not entitled to priority over the federal tax liens under the Massachusetts common law doctrines of equitable subrogation or unjust enrichment.

The mortgage at issue is secured by real property located in Marshfield, Massachusetts. In 1987, as owners of the property, Jeremiah and Deborah Folkard (“the Fol-kards”) executed a $150,000.00 mortgage note which was properly recorded in favor of the Miles Standish Federal Credit Union (“MSFCU”). Between 1988 and 1990, the government recorded six notices of tax liens on the Folkards’ property for unpaid federal taxes. The total amount of the liens, exclusive of interest accrued since recording, was $94,560.93. In 1990, the Folkards refinanced their mortgage debt, then $130,905.55, with MSFCU, executing a new note and mortgage to secure a debt of $142,000.00. At the time of this transaction, MSFCU was presumably unaware of the existing tax liens. The 1987 mortgage was discharged at the moment the new mortgage was recorded on November 26, 1990. This resulted in priority of the federal tax liens, because of their recording dates, over the new mortgage. On October 19,1992, MSFCU assigned its interest in the 1990 note and mortgage to Progressive. The record does not reflect when Progressive became aware of the record priority of the federal tax liens over its mortgage.

I. JURISDICTION

The threshold issue to be decided in this case, whether the district court properly exercised subject-matter jurisdiction over Progressive’s claim, was raised for the first time on appeal. The government argues that the district court lacked jurisdiction on two grounds: (1) the government has not waived its sovereign immunity and therefore cannot be sued; and (2) the Declaratory Judgment Act, 28 U.S.C. § 2201(a), specifically bars the relief requested. Lack of subject-matter jurisdiction can be raised at any point during litigation. There can be no doubt of our power and duly to decide the issue. See Bender v. Williamsport Area School Dist., 475 U.S. 534, 541, 106 S.Ct. 1326, 1331, 89 L.Ed.2d 501 (1986); Wells Real Estate v. Greater Lowell Bd. of Realtors, 850 F.2d 803, 813 (1st Cir.1988).

A. Waiver of Sovereign Immunity

It has long been established that the United States is not subject to suit without a waiver of sovereign immunity, and that any such waiver is to be strictly construed. Nickerson v. United States, 513 F.2d 31, 32-33 (1st Cir.1975). The government correctly argues that Progressive wrongly relies on the Declaratory Judgment Act (“the Act”), 28 U.S.C. § 2201(a), to constitute a waiver of sovereign immunity because the Act “neither provides nor denies a jurisdictional basis for actions under federal law, but merely defines the scope of available declaratory relief.” McCarthy v. Marshall, 723 F.2d 1034, 1037 (1st Cir.1983). Title 28 U.S.C. § 2410(a)(1) provides the only basis for finding a waiver of sovereign immunity in this case.

Under section 2410, the government waives its sovereign immunity in both quiet title and foreclosure actions. See 28 U.S.C. §§ 2410(a)(1), (2). A party bringing a foreclosure under this section, however, must seek a judicial sale of the underlying property. 28 U.S.C. § 2410(c). We begin by discussing whether Progressive’s claim of priority constitutes a quiet title action within the meaning of 28 U.S.C. § 2410(a)(1).

The Scope of Quiet Title Actions Under 28 U.S.C. § 2410(a)(1)

The government contends that Progressive’s claim does not fall within the coverage of section 2410(a)(1) because its claim of priority is not a quiet title action within the meaning of the statute. It follows, argues the government, that because no judicial sale has taken place, there can be no waiver of sovereign immunity and hence Progressive cannot maintain its cause of action. We disagree for the reasons that follow.

Section 2410(a)(1) has never been read to incorporate the formalistic distinctions state law pleading rules. United States v. Coson, 286 F.2d 453, 457 (9th Cir.1961). In Coson, the Ninth Circuit held that “[i]t is plain that the words ‘quiet title’ ... are not intended to refer to a suit to quiet title in the limited sense in which that term is sometimes used ... but that as used in the section here referred to it comprehends a suit to remove a cloud upon the title of a plaintiff.” Id. Both the text and the history of section 2410 support this view. The quiet title provision was inserted by amendment to the predecessor statute, following a recommendation by the Attorney General of the United States (future Justice Jackson). The heart of the recommendation stated:

[U]nder existing law there is no provision whereby the owner of real estate may clear his title to such real estate of the cloud of a Government mortgage or lien_ In many instances persons acting in good faith have purchased real estate without knowledge of the Government lien or in the belief that the lien had been extinguished.... It appears that justice and fair dealing would require that a method be provided to clear real estate titles of questionable or valueless Government liens.

H.R.Rep. No. 1191, 77th Cong., 1st Sess. 2 (1941); S.Rep. No. 1646, 77th Cong., 2d Sess. 2 (1942).

The government points out that, under Massachusetts law, a plaintiff must have both actual possession and legal title to maintain a quiet title action, see MacNeil Bros. Co. v. State Realty Co. of Boston, Inc., 333 Mass. 770, 131 N.E.2d 178 (1956 (citing cases)), and suggests that the contours of the state law cause of action should guide our interpretation of section 2410(a)(1), particularly where the state law is consistent with federal common law (as the government argues it is here). That is, the government argues that Congress intended to waive sovereign immunity only in those cases that would traditionally have been termed “quiet title” actions; because Progressive did not bring and could not have brought such an action, we should deem this case to be outside the scope of section 2410(a)(1).

If, in substance, the relief the plaintiff sought here — a declaration of the priority of Progressive’s mortgage over the government’s tax lien — is congruent with the relief available in a quiet title suit, it would frustrate congressional intent to block plaintiffs access to relief. Congress, after all, was concerned not with the niceties of common law pleading, but with practical problems facing owners whose property was encumbered by government liens. What label the. state has attached to the cause of action is a helpful but not determinative guide to the proper interpretation of the federal statute. See Harrell v. United States, 13 F.3d 232, 235 (7th Cir.1993).

The government, however, contends that the relief that Progressive seeks would not have been available in a quiet title action. Progressive does not seek to remove the government’s lien as invalid, but rather to establish the priority of its own mortgage over the concededly valid federal tax lien. Such rehef would not have been available in a traditional quiet title action, only in a foreclosure action, where valid but junior liens are extinguished in favor of a senior hen. It follows, argues the government, that because no judicial sale has taken place, see § 2410(c), there can be no waiver of sovereign immunity-

A careful reading of the authorities, however, does not support the government’s narrow portrayal of the rehef available to quiet title plaintiffs. The government principally relies on Kasdon v. G.W. Zierden Landscaping, Inc., 541 F.Supp. 991 (D.Md.1982), aff'd sub nom. Kasdon v. United States, 707 F.2d 820 (4th Cir.1983). In Kasdon, suits were brought by tax sale purchasers to foreclose all equities of redemption in properties on which the United States held tax hens. The district court held that the suits were more properly characterized as foreclosure actions than quiet title actions and that judicial sale was required in order for sovereign immunity to be waived. Id. at 995-96.

Unlike the plaintiffs in Kasdon, Progressive seeks only a determination of priority between competing hens; it never initiated a foreclosure action and did not seek to extinguish the federal hen. The Kasdon court cited United States v. Morrison, 247 F.2d 285, 289 (5th Cir.1957), for the proposition that “priorities among vahd interests are the subject of foreclosure suits,” whereas “the aheged invalidity of adverse interests are the subjects of quiet title actions.” Kasdon, 541 F.Supp. at 995. This, however, does not teh the whole story of the Morrison opinion, in which the Fifth Circuit explained that the “rehef sought [in section 2410(a)(1) claims], as traditional to equity as the woolsack, is the judicial determination of the validity and rank of the competing liens.” Id. (emphasis added). The court pointed out that it was an “unsound premise” to hold that a quiet title action “is one to extinguish the hen of the United States, rather than what it reahy is— a determination that a tax hen does not exist, has been extinguished, or is inferior in rank." Id. (emphasis added). Similarly, in Estate of Johnson, 836 F.2d 940 (5th Cir.1988), the court rejected the government’s contention that foreclosure is the only rehef available where hen priorities are in dispute. It explained:

[W]e think that section 2410, an integral part of the Judicial Code rather than an administrative mechanism of the tax structure, establishes a specific jurisdiction for these suits as bills to quiet title or for foreclosure of the private lien. The jurisdiction does not depend on the specific rehef sought, [e.g.] foreclosure. Rather it rests on the existence of the traditional controversy in which a private party asserts an ownership [interest] which is superior to the claimed hen of the United States government. (Quoting United States v. Morrison, 247 F.2d 285 (5th Cir.1957).

836 F.2d at 945.

Other courts have adopted this logic. In Brightwell v. United States, 805 F.Supp. 1464 (S.D.Ind.1992), the court reasoned:

[While] [traditionally, actions to quiet title have sought determinations of who owns particular property, ... [u]nder federal law, the definition is somewhat broader; a party may maintain a quiet title action against the United States when the government asserts that a federal tax hen exists against the property, 28 U.S.C. § 2410(a), and thus hen priority disputes have been considered “quiet title” actions [for the purposes of section 2410].

805 F.Supp. at 1469 (citing McEndree v. Wilson, 774 F.Supp. 1292, 1295-96 (D.Colo.1991)). Moreover, while a priority claim of the sort raised by Progressive has not yet been decided by this Circuit, we have held and reaffirm today that section 2410(a)(1) controversies encompass disputes concerning both the “validity and priority of liens,” as distinguished from actions seeking “their ex-tinguishment in a manner not permitted by the statutes.” Remis v. United States, 273 F.2d 293, 294 (1st Cir.1960).

These cases undercut the government’s contention that a quiet title action is appropriate under section 2410(a)(1) only where the plaintiff seeks a decree that the government’s lien is defective or invalid and seeks to have the cloud removed from his title. In support of its position, the government primarily relies on Raulerson v. United States, 786 F.2d 1090 (11th Cir.1986), where the court held that “section 2410 waives sovereign immunity only in actual quiet title actions, not suits analogous to quiet title actions.” 786 F.2d at 1091. The court concluded that plaintiff Raulerson’s complaint was not an action to quiet title because he had already forfeited title to his property and had waived his property interest by the terms of a plea agreement. Id. The instant case is not like Raulerson because Progressive has title to the Folkards’ property and has not waived its ownership interest. Furthermore, Progressive merely seeks a determination regarding the priority of its ownership interest. The Raulerson plaintiff, in contrast, sought a declaration that the IRS’s claim had priority over the valid claims of other branches of government to ensure that the IRS’s jeopardy assessment would not be satisfied from his other assets. Id. at 1091-92. Consistent with the broad construction accorded section 2410’s quiet title provision by a number of other jurisdictions, we hold that Progressive’s claim falls within the meaning and scope of the statute.

The Declaratory Judgment Act and Section 2410

In the alternative, the government argues that even if we were to hold that the district court has jurisdiction to hear Progressive’s claim, the Declaratory Judgment Act (“the Act”), 28 U.S.C. § 2201(a), nonetheless bars the court from granting the relief requested. The Act provides, inter alia, that a federal district court has the authority to grant declaratory relief “[i]n a case of actual controversy within its jurisdiction, except with respect to Federal taxes....” 28 U.S.C. § 2201(a). A claim challenging the power of the IRS to assess and collect taxes is barred by the Act. McCarthy v. Marshall, 723 F.2d 1034, 1037 (1st Cir.1983).

Similarly, “[w]hen a federal tax lien is involved, ... an action pursuant to section 2410(a) will not lie if its sole purpose is to challenge the validity of the underlying assessment.” Johnson v. United States, 990 F.2d 41, 42 (2d Cir.1993). This is because the purpose of section 2410 is “to waive the government’s immunity from suit so as to permit a court of proper jurisdiction to determine the relative position of government liens on property as against other lienors— not to permit a collateral attack on the tax assessment.” Broadwell v. United States, 234 F.Supp. 17, 18 (E.D.N.C.1964), aff'd 343 F.2d 470 (4th Cir.), cert. denied, 382 U.S. 825, 86 S.Ct. 57, 15 L.Ed.2d 70 (1965); accord, McMillen v. United States Dep’t of Treasury, 960 F.2d 187, 189 (1st Cir.1991); Falik v. United States, 343 F.2d 38, 41 (2d Cir.1965); Remis v. United States, 172 F.Supp. 732, 733 (D.Mass.1959), aff'd, 273 F.2d 293 (1st Cir.1960). Congress thus did not intend section 2410(a)(1) to extend a new remedy by which a plaintiff, whether taxpayer or third party, could contest the government’s assessment of taxes. Where a plaintiff does not challenge the underlying tax assessment, however, section 2410(a) has been recognized as a vehicle for determining lien priority. See Estate of Johnson, 836 F.2d at 945 (executor’s claim of priority of estate interest in estate over federal tax lien constitutes quiet title action where it does not contest merits of assessment); Morrison, 247 F.2d at 290-91 (property seller’s claim of priority of vendor’s lien over federal lien constitutes quiet title action where no hazard posed to revenues); First of America Bank-West, Michigan v. United States, 848 F.Supp. 1343, 1349 (W.D.Mich.1993) (nontaxpayer third party has standing under section 2410 to “merely ... assert the priority of its lien over the federal tax hen”); McEndree, 774 F.Supp. at 1296 (vendor of property eligible to maintain quiet title action alleging priority of equitable mortgage over federal tax hens where no challenge to tax assessment itself).

Progressive’s claim in no way contests the legitimacy of the government’s tax assessment or the taxpayers’ liability. It follows that “[s]ince the quiet title action specifically mandated by section 2410 is in substance a suit for a declaratory judgment,” the Declaratory Judgment Act will not operate as a wrench to deprive the district court of its jurisdiction in this case. Aqua Bar & Lounge Inc. v. U.S., 539 F.2d 935, 940 (3d Cir.1976); see also McEndree, 774 F.Supp. at 1297 (Section 2410(a) provides an exception to the Declaratory Judgment Act, as plaintiffs remedies are limited to declaratory relief).

In summary, because we conclude that the government waives its sovereign immunity under 28 U.S.C. § 2410(a)(1), and that the Declaratory Judgment Act poses no bar to the rehef sought, we accordingly hold that the district court properly exercised subject-matter jurisdiction over Progressive’s claim.

II. THE MERITS

We now turn to the substantive issue on appeal: whether Massachusetts law entitles Progressive’s mortgage priority over the federal tax liens.

Because the decision to grant summary judgment calls a legal standard into play we review the district court’s order granting summary judgment for the United States de novo. In re Varrasso, 37 F.3d 760, 763 (1st Cir.1994); Maldonado-Denis v. Castillo-Rodriguez, 23 F.3d 576, 581 (1st Cir.1994); Quaker State Oil Refining Corp. v. Garrity Oil Co., 884 F.2d 1510, 1513 (1st Cir.1989). Summary judgment is appropriate only when “there is no genuine issue as to any material fact and ... the moving party is entitled to a judgment as a matter of law.” Fed.R.Civ.P. 56(c). The district court held and we agree that because there are no disputed material issues of fact summary judgment is appropriate.

As our discussion of jurisdiction relates, it is well-settled that federal law determines the priority of competing federal and state created liens. See United States v. Rodgers, 461 U.S. 677, 683, 103 S.Ct. 2132, 2137, 76 L.Ed.2d 236 (1983); Brosnan, 363 U.S. at 240-41, 80 S.Ct. at 1110-11. Section 6321 of the Internal Revenue Code (“the Code”) authorizes the government to assert hens upon “all property and rights to property” belonging to the taxpayer for delinquent taxes. 26 U.S.C. § 6321. Section 6322 of the Code further provides that “the hen imposed by section 6321 shall arise at the time the assessment is made and shall continue until the liability for the amount so assessed ... is satisfied or becomes unenforceable by reason of lapse of time.” 26 U.S.C. § 6322.

These provisions do not, however, grant federal tax hens automatic priority over ah other hens. I.R.S. v. McDermott, 507 U.S. 447, 448-50, 113 S.Ct. 1526, 1528, 123 L.Ed.2d 128 (1993). The determination of priority is governed by the rule of “first in time, first in right.” Id. at 1528, 113 S.Ct. at 449. A federal hen which attaches first is thus senior, so long as notice is properly filed. In order for a state created hen to take priority over a later assessed federal lien it must be “ehoate” or “perfected” so that “the identity of the lienor, the property subject to the lien, and the amount of the lien are established” prior to the filing of the subsequent federal lien. United States v. New Britain, 347 U.S. 81, 84, 74 S.Ct. 367, 369, 98 L.Ed. 520 (1954); United States v. Pioneer Am. Ins. Co., 374 U.S. 84, 88, 83 S.Ct. 1651, 1654-55, 10 L.Ed.2d 770 (1963); see also Baybank Middlesex v. Elec. Fabricators Inc., 751 F.Supp. 304, 310 (D.Mass.1990); United States v. Rahar’s Inn, Inc., 243 F.Supp. 459, 460 (D.Mass.1965). Choateness of a state created lien is a matter of federal law and mirrors the standard applicable to liens asserted by the government under sections 6321 and 6322 of the Code. United States v. First Nat’l Bank and Trust Co., 386 F.2d 646, 647-48 (8th Cir.1967) (citing United States v. Vermont, 377 U.S. 351, 354, 84 S.Ct. 1267, 1269, 12 L.Ed.2d 370 (1964)). State recording statutes are relevant “only insofar as controlling federal authority dictates or sound federal policy counsels” their application. United States v. Lebanon Woolen Mills Corp., 241 F.Supp. 393, 398 (D.N.H.1964). Section 6323(i)(2) of the Code authorizes application of the common law doctrine of equitable sub-rogation where provided by state law.

Just as federal law governs the issue of priority, it is equally well-settled that , “in the application of a federal revenue act, state law controls in determining the nature of the legal interest ... in the property ... to be reached by the statute.” Aquilino v. United States, 363 U.S. 509, 513, 80 S.Ct. 1277, 1280, 4 L.Ed.2d 1365 (1960) (quoting Morgan v. Commissioner, 309 U.S. 78, 82, 60 S.Ct. 424, 426, 84 L.Ed. 585 (1940)); see also Maryland v. Louisiana, 451 U.S. 725, 746, 101 S.Ct. 2114, 2128-29, 68 L.Ed.2d 576 (1981) (courts must proceed from “the basic assumption that Congress did not intend to displace state law”). “The point at which a state created security interest attaches is a matter of state law.” ICM Mortg. Corp. v. Herring, 758 F.Supp. 1425, 1426 (D.Colo.1991) (citing Sec. Pac. Mortg. Corp. v. Choate, 897 F.2d 1057, 1058-59 (10th Cir.1990)). Federal revenue statutes “creat[e] no property rights but merely attafch] consequences, federally defined, to rights created under state law.” United States v. Bess, 357 U.S. 51, 55, 78 S.Ct. 1054, 1057, 2 L.Ed.2d 1135 (1958). For this reason, “it is critical to determine when competing state created liens come into existence or become valid.” Matter of Fisher, 7 B.R. 490, 494 (W.D.Pa.1980) (citing Pioneer Am. Ins. Co., 374 U.S. 84, 87, 83 S.Ct. 1651, 1654, 10 L.Ed.2d 770 (1963)); see also; Aquilino, 363 U.S. at 514, 80 S.Ct. at 1280-81 (Reconciliation of state law defining when a state created lien becomes effective and federal law governing priority between competing liens “strikes a proper balance between the legitimate and traditional interest which the State has in creating and defining the property interest of its citizens, and the necessity for a uniform administration of the federal revenue statutes”).

The government argues that because section 6323(i)(2) explicitly authorizes the application of local laws of subrogation and is silent as to the application of the doctrine of unjust enrichment, the district court was correct in deeming the latter doctrine inapplicable to Progressive’s claim. We disagree. While the court was correct in stating that Congress gave an “explicit directive with respect to determining the priority of federal tax liens,” it was incorrect in holding that “there is no basis upon which to presume the applicability of a common law doctrine” not expressly provided for by the statute. To essentially translate a directive for a federal scheme of priority into a preemption of state law governing the nature and extent of state created liens was unwarranted. To the contrary, federal courts should presume applicability of state common law doctrines in determining the status of state created liens. Such determinations do not contravene federal law simply because they ultimately bear on the federal issue of who was first in time in determining priority.

Before addressing the status of Progressive’s current mortgage, we briefly review its history. In 1987, MSFCU financed the Fol-kards’ first mortgage in the amount' of $150,-000.00. Between 1988 and 1990, the IRS filed six tax liens on the property, totalling $94,560.93. In 1990, MSFCU refinanced the Folkards’ first mortgage debt, then $130,-905.55, by executing a new note to secure a debt of $142,000.00. The recording of the 1990 mortgage discharged the 1987 mortgage, rendering the tax liens senior to MSFCU’s second mortgage on the record title to the property. In 1992, MSFCU assigned its mortgage to Progressive. Progressive argues that under the doctrine of unjust enrichment, MSFCU should be reinstated to its initial 1987 mortgage position and that Progressive is entitled to effectively occupy MSFCU’s reinstated position. We agree.

A. Massachusetts Common Law Doctrine of Unjust Enrichment

Under Massachusetts law, the doctrine of unjust enrichment provides that “where a mortgage has been discharged by mistake, equity will set the discharge aside and reinstate the mortgage to the position which the parties intended it to occupy, if the rights of the intervening lienholders have not been affected.” North Easton Co-op Bank v. MacLean, 300 Mass. 285, 15 N.E.2d 241, 245 (1938) (second mortgagee not prejudiced by reinstatement of first mortgage where first mortgage had been discharged by mistake upon first mortgagee’s acceptance of new note without knowledge of intervening lien) (citations omitted); see also Provident Co-Operative Bank v. Talcott, Inc., 358 Mass. 180, 260 N.E.2d 903, 909 (1970) (assignee of first mortgagee declared holder of first mortgage to prevent unjust enrichment of second mortgagee where first mortgagee discharged mortgage through inadvertence and second mortgagee’s position not adversely affected by acts of first mortgagee); Piea Realty v. Papuzynski, 342 Mass. 240, 172 N.E.2d 841, 846 (1961) (exchange of new mortgage notes for old ones did not constitute discharge of old mortgage where parties had no intent to alter substance or priority of old notes and mortgagor’s grantees did not show adverse change of position in reliance upon transaction).

The government maintains that no “mistake” was made because MSFCU intended to refinance the Folkards’ first mortgage, and so by law must have intended the consequences of its actions — i.e. the extinguishment of its original security interests. Massachusetts law, however, clearly contemplates situations where the intention to renew is not tantamount to the intention to extinguish existing security interests upon refinancing a mortgage. See North Easton Co-op Bank, 15 N.E.2d at 245; Provident, 260 N.E.2d at 909; Piea Realty, 172 N.E.2d at 846; see also Financial Acceptance Corp. v. Garvey, 6 Mass.App.Ct. 610, 380 N.E.2d 1332, 1335 (1978) (“Under Massachusetts law the renewal of a note in a different form does not operate to discharge a mortgage where, the debt itself has not been paid.... even where the new note includes a new debt”); Worcester N. Sav. Inst. v. Farwell, 292 Mass. 568, 198 N.E. 897, 899 (1935) (where bank, due to negligence of its counsel, failed to discover later mortgage on property and discharged first mortgage upon refinancing, first priority restored to bank because bank did not intend for discharge of interest); compare ICM Mortg. Corp., 758 F.Supp. at 1427 (where refinancing of deed of trust not intended to extinguish security interest, second deed of trust renewed prior obligation, resulting in priority of state created lien over federal tax lien); see generally 33 A.L.R. 149 (“It is a general rule that the cancellation of a mortgage on the record is not conclusive as to its discharge.... [a]nd where the holder of a senior mortgage discharges it of record, and contemporaneously therewith takes a new mortgage, he will not, in the absence of paramount equities, be held to have subordinated his security to intervening lien unless the circumstances of the transaction indicate this to have been his intention_”). We are thus convinced that an action based on the failure to discover a properly recorded lien is precisely the type of inadvertence the Massachusetts doctrine of unjust enrichment aims to rectify. Furthermore, we are persuaded, in accord with Progressive’s view, that no reasonable lender in MSFCU’s position would have intended, upon refinancing, to replace a first mortgage bearing the attachment of junior tax liens with a second mortgage bearing the attachment of senior tax liens, thereby relinquishing its senior interest on the property.

The district court held that reliance on the Massachusetts line of unjust enrichment cases was misplaced because such cases do not concern federal tax liens. Although it is true that Massachusetts case law does not address reinstatement of a state created lien to a position of priority over a federal government lien, we are not persuaded by the district court’s reasoning. We think that cases involving the reinstatement of mortgages which have been inadvertently discharged to the advantage of unintended and unexpected beneficiaries are sufficiently analogous to Progressive’s claim to warrant applicability. Whether or not federal tax liens are involved in such eases, to us, seems immaterial. This is mainly because the unjust enrichment doctrine operates only to restore a state created lien to the position it occupied prior to the inadvertent discharge. Reestablishing the party’s position, of itself, does not disturb the status of competing liens — whether those of a private lienor or the federal government — in terms of their effective dates of attachment for the determination of priority. It equitably determines the effective date of the state created lien independent of other existing liens. Federal law remains intact to determine both the choateness of the state created lien and its order of priority in relation to any competing federal liens.

Moreover, while Massachusetts courts have not had occasion to apply the doctrine of unjust enrichment to the federal government under this set of circumstances, federal courts have held that the doctrine is applicable where the federal government is concerned; and in several instances, have restored state created liens to their intended positions without regard for the United States’ potential loss of priority under federal law. See United States v. McCombs, 30 F.3d 310, 333 (2d Cir.1994) (holding that where government ran afoul of notice requirements of federal statute governing priority between federal tax liens and interests of subsequent purchasers, to deny subsequent holder of security interest priority over tax lien would allow government to “leap frog” the interests vested in two prior mortgage liens and would represent “a classic example of unjust enrichment”); Dietrich Indus., Inc. v. United States, 988 F.2d 568, 573 (5th Cir.1993) (holding that where purchaser who paid vendor’s senior mortgage debt as part of purchase transaction with expectation that property was free of additional encumbrances, to deny equitable subrogation remedy “would give the government- an unearned windfall in that it would elevate the government’s liens for no good reason”); Han v. United States, 944 F.2d 526, 530 n. 3 (9th Cir.1991) (holding that where purchasers of residential property paid off and discharged priority position lender unaware that additional federal tax lien attached to property, to require the purchasers to pay a portion of the taxpayer’s delinquent taxes would “unjustly enrich” and “produce a windfall” in favor of the United States).

Finally, we note that no rights of the government are impaired by MSFCU’s mortgage reinstatement. The government argues that the IRS is unlike a private creditor in that it does not bargain for interest rates and thus can never be unjustly enriched where valid liens have attached for unpaid taxes. But Progressive does not argue, nor do we suggest, that the government would be unjustly enriched by the ultimate satisfaction of its legitimate tax liens. The point is that the government could not have anticipated its current priority status because from the outset its 1988-1990 liens were clearly junior to MSFCU’s 1987 mortgage lien. Absent the inadvertent discharge of MSFCU’s mortgage in 1990, the government would not have gained serendipitous priority over MSFCU’s second mortgage lien in 1990. This resulted in the government’s unjust enrichment at the expense of MSFCU in 1990, and ultimately of Progressive in 1992. We hold that because MSFCU extinguished its initial 1987 mortgage interest by mistake upon refinancing the Folkards’ second mortgage in 1990, it should be equitably restored to its original 1987 lien position.

The government argues that the equities in favor of MSFCU may not apply to Progressive because there is no evidence that Progressive was unaware of the earlier government lien when it took the assignment of the mortgage from MSFCU. But it is horn-book law that the assignee of a mortgage succeeds to all of the assignor’s rights power and equities; and Massachusetts has applied this rule in a situation very like this case. Provident Co-operative Bank, 260 N.E.2d at 908 (“By virtue of her purchase from Provident, Mrs. Hutchinson succeeded to all of Provident’s rights in relation to the mortgage assigned, including the right to a judicial determination whether it was a first mortgage or a second mortgage.”). Thus Progressive may assert any equitable rights and defenses that MSFCU could have asserted before it assigned the mortgage.

B. Conclusion

The parties do not dispute that MSFCU’s mortgage lien was choate as of its original recording in 1987. It identified the lienor as MSFCU, described the Folkards’ property, and established the amount of the lien so that nothing more needed to be done for the lien to be “perfected.” New Britain, 347 U.S. at 84, 74 S.Ct. at 369-70. MSFCU was thus a holder of a security interest in the Folkards’ property that attached before the filing of the federal tax liens between 1988-1990. See 26 U.S.C. § 6323(h)(1). Because we hold that MSFCU should be restored to its original mortgage lien position and that Progressive should be subrogated to that same position, it follows that under the federal rule of priority, Progressive’s mortgage is first in time and hence first in right over the tax liens asserted by the government.

We reverse the district court’s decision and vacate its entry of summary judgment in favor of the United States. Summary judgment shall be entered in favor of Progressive and an appropriate declaratory judgment order shall be entered. Costs awarded to Progressive. 
      
      . The district court had prima facie jurisdiction to hear Progressive's claim because it involves issues of federal tax liens and taxation. See 28 U.S.C. §§ 1331, 1340; see also United States v. Brosnan, 363 U.S. 237, 240, 80 S.Ct. 1108, 1110-11, 4 L.Ed.2d 1192 (1960); United States v. Coson, 286 F.2d 453, 455-56 (9th Cir.1961).
     
      
      . In relevant part, 28 U.S.C. § 2410 provides:
      
        § 2410. Actions affecting property on which United States has lien
      (a) Under the conditions prescribed in this section and section 1444 of this title for the protection of the United States, the United States may be named a party in any civil action or suit in any district court, or in any State court having jurisdiction of the subject matter—
      (1) to quiet title to,
      real or personal property on which the United States has or claims a mortgage or other lien.
     
      
      . As mortgagee, Progressive holds legal title to the property, see J & W Wall Sys., Inc. v. Shawmut First Bank & Trust Co., 413 Mass. 42, 594 N.E.2d 859, 860 (1992), but it is not in possession.
     
      
      . Congress did intend section 2410(a)(1) to be a basis for taxpayer challenges to the procedural validity of tax liens. See Robinson v. United States, 920 F.2d 1157, 1161 (3d Cir.1990) (where IRS failed to send notice of deficiency to taxpayer when lien filed); Rodriguez v. United States, 629 F.Supp. 333, 336 (N.D.Ill.1986) (where IRS failed to send notice of deficiency when levied on property); Ringer v. Basile, 645 F.Supp. 1517, 1525-26 (D.Colo.1986) (where IRS violated own procedures when seized property). Likewise, with regard to third party nontaxpayer plaintiffs, courts have adopted the view that "[t]he validity of a lien, depending upon compliance or noncompliance with statutory requirements, or the priority of a lien validly filed is quite a far cry from permitting a third party to attack the tax assessment upon which a properly filed lien is based.” Pipola v. Chicco, 169 F.Supp. 229, 232 (S.D.N.Y.1959), modified, 274 F.2d 909 (2d Cir.1960). Progressive does not challenge the procedural validity of the tax liens. It is a matter of record that the liens were properly filed with the Plymouth County (Massachusetts) Registry of Deeds.
     
      
      . The Code provides that "[t]he lien imposed by section 6321 shall not be valid as against any purchaser, holder of a security interest, mechanic’s lienor, or judgment lien creditor until notice thereof....” 26 U.S.C. § 6323(a).
     
      
      . "Where, under local law, one person is subro-gated to the rights of another with respect to a lien or interest, such person shall be subrogated to such rights for purposes of any lien imposed by section 6321 or 6324." 26 U.S.C. § 6323(i)(2).
     