*3492*347A solution of the controversy here presented involves a construction of subdivision í of section 3317 of McClain’s Code, which, so far, as material, is as follows: “The liens' for the things aforesaid, or the wort, including those for additions, repairs and betterments, shall 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 such erection building, or improvement belongs, or is erected or put. If such material was furnished or labor performed in the erection or construction of an original and independent building, erection, or other improvement commenced since the attaching or execution of such prior lien, incumbrance, or mortgage, the court may, in its discretion, order and direct such building, erection, or improvement to be separately sold under execution, and the purchaser may remove the same within such reasonable time as the court may fix. But if, in the discretion of the court such building should not be separately sold, the court shall take an account and ascertain the separate values of the land, and the erection; building, or other improvement, and distribute the proceeds of 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, erection, or .other improvement. * * * In case thei premises do not sell for more than sufficient to pay off the prior mortgage or other lien, the proceeds shall be applied on the prior mortgage or other liens.” It is not claimed that the lower court erred in its finding that the building upon which appellee had his lien could be removed without material injury to the remaining security of appellant, and without seriously lessening the value of such structure. Such findings, we take it, were necessarily involved in the exercise of the court’s discretion *348in favor of the mechanic's lien holder. Bnt it is broadly claimed by appellant that under no circumstances can the holder of a mechanic's lien be given a preference, as against an independent building, over a prior mortgage of the land, unless the value of the land, with such-improvement, exceeds the mortgage debt, and this claim is based upon the closing paragraph of the quoted section. If appellant is correct in his construction of this section, then, although it in terms gives to- the holder of a mechanic's lien such preference, yet it denies him the right in all cases where priority could be of any advantage to him. We cannot think the preference here given the mechanic's lien holder is of this barren character. A proper construction of this statute, we think, must give to the holder of -a mechanic's lien against an independent building a priority of right in every case where the court shall find as a fact that such building can be removed without material injury to the security of the earlier lienholder; but where no- such finding is made, the land must be sold, and the purchase price applied -first in payment of the prior incumbrance. This construction, we think, has support in former decisions' of this court. We will briefly review some of the cases, and the statutes under which they were decided. Section 1855 of the Revision of 1860 corresponds with the provision in question. It i-s as follows: “The lien for the things aforesaid, or work, shall attach to -the buildings, erections or improvements, for which- they were furnished or the work was done, in preference to any prior lien or incumbrance, or mortgage upon the. land, upon which said buildings, erections or improvements have been erected or put, and any person enforcing such lien, may have such building, erection or improvement sold under execution, and the purchaser may remove the same within a reasonable time thereafter.” With some unimportant verbal changes, this section was re-enacted in the Code of 1873. *349With the law in this form, it was held that the lien of the mechanic for repairs or additions to a building would not be preferred to an existing mortgage on the land, b.ut that such priority was limited to cases1 where the mchanic’s lien was held against an independent or original structure, which could be removed. Getchell v. Allen, 34 Iowa, 559; O'Brien v. Pettis, 42 Iowa, 293. In Conrad v. Star, 50 Iowa, 470, it is said: “We are of the opinion that, under the law existing prior to the act of 1876, the only manner of establishing the priority of a mechanic’s lien over a pre-existing incumbrance upon the land was by the sale and removal of the building, and that, where the nature of the improvements is such that it cannot be removed, the lien of the mechanic must be postponed to that of the prior incumbrance upon the land.” In Stockwell v. Carpenter, 27 Iowa, 119, it is held that, in case of a.n independent structure that could be removed without material detriment to the premises, the liens of the mechanic took precedence of a prior vendor’s lien, and a sale of the building was ordered, although the vendor’s claim exceeded in amount the value of the premises. Such was the law at the time of the enactment of chapter 100, Laws Sixteenth General Assembly, of which section 3317, McOlain’s Code, is a part. While this act effected many and radical changes in the then existing law relating to mechanics’ liens, a careful reading of subdivision 4 of said section will malee it manifest that the general assembly in its adoption intended only to state in express terms in the statute the law as it then existed, as to priority of liens, in judicial interpretation. The cases cited by appellant do not conflict with the construction we give to this statute. Bartlett v. Bilger, 92 Iowa, 732, was a case in which the mechanic’s lien holder claimed a preference as to the real estate as well as the buildings, and this was disallowed. In Kiene v. Hodge, 90 id. 212, the lower court failed to find that the *350building could be removed, but ordered a sale of the whole premises. Miller v. Seal, 71 id. 392, holds only that the lower court did not abuse its discretion in refusing to order the sale and removal of the building. In Curtis v. Broadwell, 66 id. 662, the lower court ordered a sale of the land and buildings to satisfy all liens; and in Bank v. Schloth, 59 id. 316, the lien claimed was for an addition to an existing building. On the other hand, we have in Luce v. Curtis, 77 id. 347, a case in which, under section 3317, this court approved an order for the sale and removal of a building as against a prior mortgage; and while it is true the value of the premises does not appear, we think it would be an exceptional case where the holder of the mechanic’s lien would resort to his right to the building alone, if there was a prospect of his realizing something on a sale of the whole premises. The construction here announced is in accord with the words of the statute, and it is not inequitable, for it leaves to the prior mortgagee or lien holder all that he had when lxis interest attached. For the reasons stated we think the decree of the lower court must be affirmed.