BLAND, P. J.
M. S. Carter & Company contracted to build all bridges, houses and an incline in the construction of the Gray’s Point Terminal Eailroad running from Delta in Cape Girardeau county to Gray’s Point, Missouri. The appellants, through Lyons, contracted with Carter & Company to furnish all the piling necessary to be used in the construction of bridges and incline for the road. After filling their contract the appellants filed the following ac*486count as the basis of a lien against the road, except the last item of $28.05. to wit:
“Cape Girardeau, Mo., November 12, 1898.
“M. S. Carter & Co. to Harty & Lyons, Dr.
Eor piling furnished the Gray’s Point Terminal Railroad :
Eeb. 1, 1898. .To 17740 lin. feet hewed cypress piling at 16 cents per foot................$2,838 4d
April 30, 1898. To 33988 lin. feet oak piling at 16 cents per foot 5,438 08
Oct. 11, 1898. To 320 lin. feet oak at 16 cents.......... 51 20
Jan. 31, 1899. To hauling . . .. ‘ 28 05
By cash................ $7,900 00
Balance due............ 455 73
$8,355 73 $8,355 73”
In due time appellants brought this suit to establish and enforce their lien against the railroad and for personal judgment against M. S. Carter & Company. The petition' is in proper form and is unobjectionable.
The answer of the railroad was: Eirst a general denial; second, a defect of parties defendant; third, a waiver of lien privilege, if any appellants had; fourth, a plea of payment; fifth, that the lien was filed out of time.
The lien paper was filed November 12, 1898, and within four months from the date of the last item of the account, and was therefore filed in time. The suit was begun February 2, 1899. On November 5, 1898, the Gray’s Point Railroad Company leased for a period of fifty years all of its property to the St. Louis Southwestern Railway Company. This lease was duly recorded in the office of the Secretary of State, but was not recorded in the recorder’s office of any county through which the railway runs. The evidence for appellants tended to prove that the balance *487of $455.73 claimed by them to be due was correct. On the part of defendants the evidence tended to prove that appellants had been overpaid by Carter & Company. It was in proof that about 3,000 linear feet of piling furnished by appellants was not used in the construction of the road. The payments made by Carter & Company were applied on general account, and not on any particular order or orders given by them to appellants for piling, or on any special delivery made by them. The contract for the piling was made with Lyons only. Harty was not known in the transaction. All orders were given to Lyons; all payments were made to him, and the entire transaction by Carter & Company was with Lyons only, and it was not known that Harty had any interest in the contract, or that he was in any wise connected with Lyons in filling the contract, until this suit was brought.
The court, sitting as *a jury, rendered judgment against Carter & Company in favor of appellants for the balance claimed to be due, but denied the lien, and on this branch of the case gave judgment for the defendant railroad company.
1. By an instruction the court declared the law to be, that the St. Louis & Southwestern Railroad Company was a necessary party defendant. The giving of this declaration of law is one of the assignments of error made by appellants. Section 6747, Revised Statutes 1889, provides: “Any person or corporation owning or operating the railroad to which said liens may apply shall, in each instance, be made a party defendant in all suits for enforcing said liens.” * * * * * In Mackler v. Railroad, 62 Mo. App. 677, a case in which the lessee of a railroad was made a party defendant to enforce a lien against the road, but the owner was omitted, it was held by this court that the owner was an indispensable party defendant. The lien to be established must be against the whole road, and not against *488any separate part or interest in tbe road, and as the entire property is to be affected by the lien, the owner is an essential party defendant to make the judgment effectual. Knapp v. Railroad, 74 Mo. 374. The St. Louis and Southwestern Eailroad Company was not the owner of the road, and did not become a lessee until after the material was all furnished and the appellant’s right to file their lien had accrued, nor until after notice of their intention to file the lien had. been given to the owner of the road. Hence it does not present a case strictly within the letter of the above statute, which contemplates the joinder of all persons owning or operating the road at the time-of the accrual of the lien, and is thereby clearly distinguishable from the decision of this court in 62 Mo. App. supra. We therefore conclude that the omission of the lessee as a party merely renders the lien nugatory as to its rights under the lease, but does not prevent the establishment of a lien—for what it may be worth—against the interest of the owner of the road, and this seems to be the ruling of the supreme court in 76 Mo. 361.
2. The .court instructed the jury in effect that if Lyons made the contract with Carter <fc Company, and that a part of the material was furnished by Lyons and subsequently Harty became a partner with Lyons in providing any part of the material sued for, the lien for the whole of the material could not be enforced by Lyons and Harty. As- a naked declaration of law the instruction is correct, but it should not have been given in this case, as there is not a ray of testimony to support it. The only testimony on this point is that of Lyons, who swore that before he made the contract, he and Harty agreed, if the contract could be secured, they would go together and fill it, and that all the material was furnished by the partnership of Lyons and Harty.
3. Appellants complain of the fourth declaration of law given for respondents, which declares that appellants *489were not entitled to a lien for any material furnished which did not enter into the construction of the road, and that the burden was on them to show that all or some part of the material listed in the account entered into the construction, and to show what part was not used, and that if they had not done so, the findings should be for the defendant railway company. It is conceded that about 3,000 linear feet of piling was furnished which was not used. Appellants’ contention is, that as all the payments were made on general account for piling, it was the duty of the court to apply the payments to the extinguishment of the nonlienable item, that is to payment for piling not used, and thus secure to appellants a lien for the balance due on all the piling furnished. The rule is, that where a creditor holds several claims against his debtor, and the latter makes a payment without giving directions as to its application, the creditor may make the application; if neither the creditor nor debtor makes the application, the law will apply it to the debt which first accrues, unless justice and equity demand a different application. Beck v. Haas, 111 Mo. loc. cit. 268. And the law in such circumstances will apply the payment to the debt whose security is most precarious. Poulson v. Collier, 18 Mo. App. loc. cit. 608. Or, where one is secured and the other unsecured, the law will apply the payment to the unsecured debt. Goetz v. Piel, 26 Mo. App. 634; Price v. Merritt, 55 Mo. App. 640. In the latter case it was held that where an account contained lienable and nonlienable items under the mechanics’ lien law, the court in a suit to enforce a mechanics’ lien properly applied the unapplied payments to the payment of the nonlienable items. There are no separate and distinct debts or accounts between appellants and Carter & Company; there is but one general running account. There are no articles embraced in the account that axe nonlienable under the statute, and hence there is no occasion to invoke the rule asked for by appel*490lants. The account or debt is all for lienable articles had they all been used, and there is but one account to which payments can be applied, unless we arbitrarily segregate from the general account the piling furnished but not used in the construction of the road from that which was used. We do not think that this should be done. To do so seems to us would be a gross injustice to the owners of the road. The item for $28.05 for hauling January 31, 1899, was correctly •excluded by the court from the lien account as the work was done after the lien account had been sworn to and filed.
Eor error in giving instructions numbers 1 and 4 for respondents, the judgment is reversed and the cause remanded.
Judge Bond concurs; Judge Biggs absent.