This case seems t'o have been tried without strict regard to the issues formed by the pleadings. In May, 1814, the plaintiffs proposed to erect a three-story briclc building on their own lot, the brick and stone work to be done by themselves. They made a contract with the defendants to furnish the material for the wood work and to do the carpenter work on this building for $2,800. No time was fixed when the plaintiffs should pay, but they made advances on the contract, from time to time, as the work progressed. In July following, the building was totally destroyed by fire, without the fault of either party. At this time the plaintiffs had made advances to the amount of $1,814.18. The defendants had performed labor and furnished material, which was actually put into the building, of the value of $1,155.05. They had also done labor upon, and furnished, material which was not used in the building, of the value of $464.11, which was destroyed by the fire. After the destruction of the building the plaintiffs concluded to rebuild, and requested the defendants to furnish the material and to do the carpenter work on the new building. The defendants denied that they were under any obligations to do this at their own expense. The complaint obviously goes upon the theory that the defendants were bound to do the work and furnish the material on the new building without any other compensar tion than that specified in the original contract. The plaintiffs sought to recover all advances made, as well as damages for the breach of the agreement. The answer of the defendants, in brief, is that they were to be paid under the *566contract for labor and material as the work progressed; that they were to be at no risk for loss or damage by fire; that the plaintiffs alone were to sustain any such loss; that they had not been fully paid for work which they did, and for materials which they furnished for the building; and seek to recover, by way of counterclaim, the amount due them over and above advances.
The case seems to have 'been tried without objection, both by the referee and court, on the assumption that the parties were excused, in consequence of the destruction of the building, from the further performance of the contract. A labored investigation was gone into, and testimony taken to ascertain the amount of advances made by plaintiffs to apply on the contract; the value of the labor done and materials furnished which was actually put into the building; the value of the labor done upon and of the materials which were not used; and what it would cost the defendants to complete the building according to the contract. The court finally decided, on a review of the report of the referee, that the plaintiff must bear the loss of all labor and material actually put into the building; that the defendants must sustain the loss of the labor and material not used; and gave the defendants profits on their contract; but charged them with the excess of advances over and above what they were entitled to receive on this basis.
Now the whole contention in this court is whether the plaintiffs, under the circumstances, can recover back the excess thus paid. It seems to us but equitable and just to allow them to do so. They have abandoned all claim for damages arising from the failure of the defendants to completely perform the contract. In other words, they abandon the claim counted on in their complaint. They make no question here as to the right of the defendants to recover for work done and materials furnished which were actually put into their building. Probably, under the rule laid down in Cook v. Mc*567Cabe, 53 Wis., 250, they could not successfully do so. Nor ■do they contest the right of the defendants to whateyer profits they might have made on their contract had they completed it. They virtually take the same position as the defendants, that the contract was mutually given up after the fire. Now, ■can they not recover for over advances ? The learned counsel for the defendants insists that they cannot recover this excess of advances over and above the value of the labor done and materials furnished which went into the Building, and the profits on the contract, because it was not alleged in the complaint nor proven on the trial that a demand was made before suit brought. It seems to us it is a sufficient answer to this objection to say that it is taken for the first time in this court; therefore ought not to prevail. We have made a sufficient reference to the complaint to show that the plaintiffs have entirely changed their ground. They fi nally treated the action as one brought to ascertain the value of the labor done and materials furnished up to the time of the fire; or, in other words, to determine the amount of thq prorata compensation which was due the defendants upon the contract. And the record shows that the only litigation was upon the issue tendered upon the counterclaim. In the counterclaim the defendants alleged that they had done more work and furnished more material than they had been paid for, and that the sum of $240.Y0 is still due them on the contract. They asked judgment for that amount. Had they established this claim by evidence, they would doubtless have recovered of the plaintiffs that sum. Now, when the proof shows that the defendants have been overpaid, why, on the other hand, should not the plaintiffs have judgment for the excess ? Under the circumstances, we think they should, and that the doctrine of the cases relied upon by the learned counsel for the defendants, to the effect that in an action for money had and received to the use of the plaintiff a demand must be alleged and proven, does not apply. By the course taken by both *568sides on the trial, the ease is taken out of that rule, moro especially in view of the fact already mentioned, that the-objection is made for the first time in this court. But the same counsel further insists that this excess cannot be recovered back because the money was voluntarily paid to apply on the contract. It is doubtless true that all the advances, were intended to be so applied when made. But the building was destroyed by fire without the fault of either party ' before the defendants had earned all the advances. The continued existence of the building and the earning of these advances were, as it appears to us, conditions implied when the payments were made. In consequence of the destruction of the building a full performance had became impossible, or the parties saw fit to treat the contract as at an end. And in this litigation they have acted upon the assumption that they were not only excused from further performance, but that their rights under the contract were to be fixed and determined as at the time the fire occurred.
The facts present a case quite analogous to the one suggested on the brief of plaintiffs’ counsel. He says: Suppose A. sells and agrees to deliver to B., at his warehouse, all the wheat in his barn. B., relying on a fulfillment of the-contract, makes advances largely in excess of any wheat delivered. While the contract is in fieri the barn and contents are accidentally destroyed by fire, so that further performance becomes impossible. Is there any rule of law or principle of justice which will allow A., under these circumstances, to retain all the advances because they were voluntarily made? We know of no such rule or principle. In saying this it is not intended to impugn the soundness of the principle that money voluntarily paid, under certain circumstances, cannot be recovered back. But we do not think the principle applies here.
The circuit court did not give the plaintiffs as large a judgment as they were entitled to upon its view of the case, be^ *569cause they were willing to abide by tbe amount awarded them by the referee. We certainly can see no error in the record of which the defendants can complain, and the judgment of the circuit court must therefore be affirmed
By the Court.— Judgment affirmed.