after making the above statement, of facts, delivered the opinion of the court.
The Federal question in this case arises because of the legislation of North Dakota subsequent to 1884, the time of the execution of the mortgage to the Travelers’ Insurance Company, the plaintiff in error contending that by reason of such legislation its rights, with reference to the property herein, have to some extent been taken away or unfavorably affected, without due process of law, and it also contends that the subsequent legislation operated to impair the obligation of a contract arising out of the execution of the mortgage already mentioned, its foreclosure and the sale of the property to the insurance company, and its assignment to the plaintiff in error.
*553¥e think it was the legislative intent that the last statute should apply to past transactions and that no substantial rights of the plaintiff in error are thereby unfavorably affected,-because, in our opinion, there .is no such material difference in the several statutes, so far as regards the rights of the parties, as to forbid the application of the latest statute to a case where the mortgage was given and the materials furnished prior to its passage. The. difference between that statute and its predecessors, so. far as relates to the point in question here, has special reference to the remedy only and to the manner of executing the provisions of the statute in force at the time of the execution of the mortgage and also when the work was done and the materials furnished. It in reality solely affects the remedy, and does not thereby substantially alter those rights of the mortgagee or his representatives which existed when the mortgage was made. A mechanic’s lien law was then in existence, and the mortgage was taken subject to the right of the legislature, in its discretion, to alter that law, so long as the alterations only affected the means of enforcing an existing lien, while not in substance enlarging its extent or unduly extending the remedy to the injury of vested rights. So long as those rights remain thus unaffected the subsequent statute must be held valid, although the remedy be thereby to some extent altered and enlarged. Looked at in this light, the legislation under review cannot be held to violate any rights of the plaintiff in error protected by the Constitution of the United States.
Section 655 of the old act provided for the lien- and gave it' to those persons who performed labor upon or furnished materials for a building, upon complying with the provisions of the chapter, (31). Section 666 provided for the enforcement of the- lien in certain cases, and granted the right to any person having a lien to enforce the sale of the building, and to the purchaser the right to remove the same within a reasonable time. These two sections are reproduced in substantially the same language in the act of 1881, (in force when the work was done,) as sections 5469 and 5480 of the Compiled Laws of 1887, there being an immaterial addition in section 546.9 to section 655, whose place it takes.
*554By the lav? of 1895, which was in force when this action was • commenced', the old section 655 is somewhat elaborated by section 4788 of the Be vised Code of that year, but the substance of the old section, so far as the facts of this case touch it, remains the same in the new section.
Old section 666 is amended by section 4795, Eevised Code, which provides more in detail for the carrying out of the provisions of the old section. The old section itself provided for the. enforcement of the lien which was given by that statute, and the last statute it must be remembered neither created nor extended that lien, but somewhat amplified the means to enforce or discharge it. By this alteration the prior statute was not altered to the disadvantage of the owner or his mortgagee in regard to those rights which the person furnishing the materials or performing the labor had under such prior statute. In that prior statute it was provided that the lien for the work done or materials furnished should attach to the buildings, erections or improvements for which they were furnished or done in preference to any prior lien or incumbrance or mortgage upon the land upon which the same was erected or put, and any person enforcing such lien was granted the right to have the building, erection or other improvement sold under execution, and the purchaser had the right to remove the same within a reasonable time.
By the last act (section 4795) the same right still exists; the building may be sold separately and the purchaser may remove the same. There is added, however, the further provision which permits the court for the best interests of all the parties to sell the land and the improvements together, and after ascertaining the separate values of the land and of the building, provision is made for the distribution of the proceeds of the sale so as to secure to the prior mortgage or other lien priority upon the land and to the mechanic’s lien priority upon the building into which his labor or materials have entered.
True it is that the property was sold under the foreclosure when there was no right to sell the land in connection with the building for the purpose of paying the liens on the latter.. The liens on the building, however, were there, and the building *555could be sold and removed to pay tbe amount thereof, and under the foreclosure the purchaser bought subject to that existing right. He thus obtained a title under which his building could be sold from under him and removed from the land. Under the amended statute the court may sell all the property, land and building together,, and return to the owner the value of the land and the surplus arising from the building after payment of the liens. As the liens were in • existence when the mortgage was foreclosed, we think the purchaser took title subject to the right of the legislature, in making a reasonable and proper amendment of the law, to provide in foreclosing the liens, for the sale of the whole property and the return to the owner of the lot of the full value thereof in money, instead of allowing him to. keep the lot and have the building thereon sold and removed. The plaintiff in error’s property was already in the grasp of the statute creating the liens when the mortgage was foreclosed, and that fact is the material one for consideration with reference to the statute and its amendment.
The plaintiff in error asserts that this change in the law rendered the mortgage security less valuable, and that, therefore, it impaired the obligation-of the contract and was void. This is mere assertion, and we do not assent to its correctness. A mortgage which is already subject to the right of subsequent lienors, who furnish materials or labor in the erection of a building, to sell the same and have it removed for the payment of the liens, is not in our judgment reduced in value • by the provision contained in the amendment under consideration.
Some reference has been made to a decision of the Supreme Court of North Dakota, decided before the foreclosure of the mortgage, and it has been said that it is therein decided that section 5480 of the Compiled Laws of 1887, which, as wé have stated, is identical with section 666 of chapter 31, above mentioned, (in force when the mortgage was executed,) does not give any lien as against a mortgagee or one representing him in a case like this, because such lien could not be enforced without a demolition of the building, and in such case no lien is given, while by the - latest statute it is asserted that the lien is given, and also an effective means of enforcing it. In brief, it *556is urged that a lien is given by the last statute as against a mortgagee or his representative, in a case where it did not exist when the mortgage was made, as the Supreme Court of the State decided, and that such decision had been given when the mortgage was foreclosed and the property bid in by the mortgagee and then assigned to the plaintiff in error, and it is claimed that the subsequent statute giving the lien was a clear violation of the contract as against the plaintiff in error. James River Lumber Company v. Danner, 3 N. D. 470, is the authority referred to for this contention, but an examination of the facts and the opinion of the court therein shows that no such proposition was decided. In that case there was a mortgage upon the whole of the property, which consisted of a lot with a brewery erected thereon. A fire occurred which to some extent damaged, without destroying, the building. It was therefore repaired, and for the materials for such repairs and for the labor expended on the building lions were filed, and the claim was made that they were liens superior to the mortgage thereon at the time the materials were furnished and the labor performed. This the court held was not the true construction of section 5480 ; that while that section gives the lienor the right to sell the building and the purchaser the right to have it removed, yet, no authority was given to sell the entire building to pay the lien of one who had only repaired it while a recorded mortgage existed against the land at the time he made the repairs. It was said that a lien for repairs upon a building covered by a mortgage at the time of the repairs would not justify a sale and removal of the building as against such mortgage ; that priority of lien was given in cases where the whole erection might be sold and removed without unlawfully encroaching upon the right of the mortgagee of the land, and that a priority of lien existed only when a new structure had been put upon the land subsequently to the execution of the mortgage, and the one who claimed a prior lien must have contributed. to the erection of such building by the furnishing of materials or the doing of work. And the court further held that as the work on the partially.destroyed, building was not begun until some time after the recording of the mortgage on the *557whole property, the lienor could not procure a sale of the whole building and give to the purchaser the right to remove it, and as this could not be done as against the mortgagee, the priority of lien did not exist. The court, however, recognizes in terms the existence of a lien under that statute, when a new structure has been put upon the land subsequently to the execution of the mortgage, if the person claiming the lien has contributed to the erection of the building by furnishing materials therefor or performing labor thereon.
In this case, the building did not exist at the time the mortgage was executed, and the liens were filed to secure payment for the materials used in its construction and the labor performed upon it, and no decision of the Supreme Court of North Dakota has been called to our attention holding that under such circumstances there would not have been a lien upon the building in favor of the mechanics and prior to that of the mortgage executed before its erection. In such case as this it is clear that under the act in force when the mortgage was executed and "when the labor was performed, a lien on the building was created by virtue of that act, and that the building could have been sold under it and the purchaser would have had the right to remove it notwithstanding, in order to do so, he would have been compelled to demolish the entire building.
One of the amendments contained in the last statute, which provides a means for the enforcement of a lien by the sale of the whole premises in the case of repairs upon a building already covered by a mortgage, was probably passed because of the above, decision of the Dakota court, and we need-not concern ourselves as to its validity, because the plaintiff in error does not occupy, such a position as to enable it to raise that question, the whole building in this case having been erected subsequently to the mortgage. The same may be said as to any question which might upon other facts be raised because of the cutting off of an existing mortgage not yet due and the (claimed) impairment of the obligation of a contract by the sale of the premises .under the provisions of the amended statute.
The mortgage in this case was past due and had been foreclosed and the land sold in 1894, subject to the lien on the *558building provided by the statute then in existence. One who does not belong to the class that might be injured by a statute .cannot raise the question of its invalidity. Supervisors v. Stanley, 105 U. S. 305; Clark v. Kansas City, 176 U. S. 114, 118; Lampasas v. Bell, 180 U. S. 276, 283.
The amendments to the old section 667, relating to the bringing of such, an action as this, are simply of the same nature as those above discussed, amplifying to some extent, but not mate-, rially, the powers of the court as to the remedy.
The decision of the main question in this case is fatal to the rights claimed by the plaintiff in error, and the judgment must, therefore, be
Affirmed.