
200 Cal.App.3d 1442 (1988)
246 Cal. Rptr. 601
STANISLAUS PUMP, MACHINERY & CONSTRUCTION CORPORATION, Plaintiff and Respondent,
v.
CITY OF MODESTO, Defendant and Appellant.
Docket No. F007309.
Court of Appeals of California, Fifth District.
May 5, 1988.
*1443 COUNSEL
McCormick, Barstow, Sheppard, Wayte & Carruth and David H. Bent for Defendant and Appellant.
Stockton & Sadler and James L. Sadler for Plaintiff and Respondent.
[Opinion certified for partial publication.[*]]
*1444 OPINION
BROWN (G.A.), J.[*]
Respondent, Stanislaus Pump, Machinery & Construction Corporation (contractor), filed a complaint seeking damages for breach of contract against appellant, City of Modesto (City), arising out of a work of public improvement relating to a municipal sewer system. In its answer to the complaint, the City included as an affirmative defense that it had withheld sums from contractor representing the cost of the traffic pavement markers which it had deleted from the contract, and the amount paid to S & H Insurance Company (Surety), the surety on the payment and performance bond furnished by contractor to City. The City also filed a cross-complaint seeking recovery from contractor for an item not at issue in this appeal and indemnity from Surety pursuant to a hold harmless agreement between them. The cross-complaint was bifurcated to the extent it sought relief against Surety and is not an issue in this appeal.
Following a court trial, it was ordered that contractor recover judgment against City in the amount of $59,524.39, plus interest. Pursuant to the City's request, a statement of decision was proposed and, after a hearing on City's objections, was adopted as modified. Thereafter, the court denied the City's motions for a new trial and to set aside the judgment. The appeal is from the underlying judgment and the order denying the two motions after judgment.

FACTS
Contractor bid on and was awarded the contract for the repiping of the Rose-Celeste lift station for $179,079. Under this contract, contractor was to install a pipeline, a wet pit for the purpose of containing raw sewage, and a dry pit or lift station. Additionally, an existing wet pit was to be connected to the new wet pit.
Shoring was required for the excavation of the wet and dry pits, and the trench needed to connect the existing wet pit to the new wet pit. At a preconstruction conference, the City approved the use of steel sheet piling for shoring all of the excavations.
The work was conducted in three phases: (1) installation of the pipeline along Rose Avenue; (2) installation of the wet and dry pits at the intersection of Rose and Celeste; and (3) connection of the existing wet pit to the new wet pit. Construction of the first phase proceeded without incident.
*1445 Sometime in March, City decided not to abandon the old lift station as originally planned and to modify the electrical system. Following a verbal request, contractor received change order request No. 1 from City. It took 21 working days to process this change order. During this period, City ordered the work suspended on the entire project.
Following completion of the second phase, connection of the new and old wet pits was undertaken. City informed contractor that it would not be able to use steel sheet piling to shore the excavation because the use of such shoring would necessitate a total closure of the intersection. City was also concerned about the vibration from the equipment used to install the shoring. City suggested that the excavation be shored with hydraulic jacks connected to sheets of plywood.
Contractor began excavating the trench between the new and old wet pits on May 13 using the hydraulic jack shoring. Due to no fault of contractor, a cave-in occurred and a portion of the trench collapsed. The hydraulic shoring which had been in the trench was destroyed. Following the collapse, trenching was completed by use of a tapered excavation, and the wet pits were connected.
The project was completed and accepted by City. However, contractor received only three progress payments totaling $23,177.58 out of the six payments it was entitled to under the contract. City retained the balance. Stop notices were filed with City by suppliers of labor and materials who did not receive payment from contractor. City paid a portion of the funds withheld in response to these stop notices to Surety pursuant to an agreement between them. Surety paid out only a portion of this money to the stop notice claimants and retained the balance.
The trial court found that City was responsible for both the delay in the execution of change order No. 1 and the collapse of the trench and awarded contractor damages arising therefrom. Contract sums found to have been improperly retained by City were also awarded. The court further held that City's payment to Surety violated Civil Code section 3186 and awarded contractor all contract sums not paid to stop notice claimants by Surety. It is certain aspects of this damage award which City challenges on appeal.

DISCUSSION[*]
.... .... .... .... .... .


*1446 I-IV[*]
.... .... .... .... .... .

V

Whether the Trial Court Erred in Awarding Contractor the Amount Paid by City to Surety Which Was Not Paid to Stop Notice Claimants
As required by Surety before issuing the bond, contractor entered into a general indemnity agreement with Surety wherein, in the event of default by contractor in the payments to subcontractors and suppliers, contractor agreed to assign any and all sums due, or which thereafter became due under the contract to Surety. The trial court found that Surety was an assignee of contractor.
City withheld $62,026.70 from contractor pursuant to the public works stop notices filed with it but did not pay the stop notice claimants. This sum represented the total amount of stop notices filed with the City. Contractor filed a petition in bankruptcy on September 2, 1982. On December 2, 1982, City entered into an agreement with Surety wherein City paid Surety $42,318.54 representing a portion of the funds which had been withheld from contractor pursuant to the stop notices. Surety paid the stop notice claimants $29,342.72, but retained $13,975.84.
The trial court found that City's payment to Surety violated Civil Code sections 3186 and 3193 and that contractor was liable to all stop notice claimants for provable claims which had not been paid or otherwise discharged. The court concluded that contractor retained an equitable interest in the collateral security pledged to Surety and was therefore entitled to all contract sums not paid to stop notice claimants by Surety in the amount of $13,975.84. The court concluded contractor was entitled to judgment in that sum against the City. There is no finding or allegation that contractor subsequently paid this amount to the stop notice claimants. (1a) The City contends it was error for the court to enter judgment for this sum against the City. We agree.
Civil Code section 3186 provides that "[i]t shall be the duty of the public entity, upon receipt of a stop notice ..., to withhold from the original contractor, or from any person acting under his authority, money ... due or to become due to such contractor in an amount sufficient to answer the claim stated in such stop notice and to provide for the reasonable cost of *1447 any litigation thereunder." Thus, the public entity is required to withhold the money from the original contractor. (Westinghouse Electric Corp. v. County of Los Angeles (1982) 129 Cal. App.3d 771, 781 [181 Cal. Rptr. 332].) Further, Civil Code section 3193 provides that "[n]o assignment by the original contractor of any of the money due or to become due to the original contractor under the contract ... whether made before or after the service of a stop notice, takes priority over a stop notice ... and such assignment has no effect on the rights of the stop notice claimants." Thus, the City erroneously paid the withheld funds to Surety as contractor's assignee. However, contractor did not retain an interest in the assigned contract so as to enable it to recover these funds from the City.
(2) When an assignment is made for collection or as collateral security, the assignor retains the equitable interest in the thing assigned and therefore can maintain an action for its recovery. (Rauer's Law, etc. Co. v. Higgins (1946) 76 Cal. App.2d 854, 857 [174 P.2d 450]; Webb v. Casassa (1927) 82 Cal. App. 307, 312 [255 P. 541].) (1b) The principles recited in these cases do not control the instant case. Here the assignment of contractor's interest in the contract to Surety occurred due to contractor's failure to pay the stop notice claimants. Once this default occurred and the stop notices were filed, City was prohibited from paying these sums to contractor or his assignee under Civil Code sections 3186 and 3193. After the stop notices were filed, contractor lost the right to collect the amount of those claims from the City or his assignee. The City has an absolute statutory duty to pay the valid amounts of those claims to the stop notice claimants and no one else. This statutory scheme gives the maximum protection to the stop notice claimants and their interest is the interest the entire statutory arrangement is designed to protect. Thus, permitting contractor to recover the money erroneously paid to Surety from the City would cause the assignment to bestow a right upon contractor it otherwise would not have had, altering the statutory scheme. It would be anomalous indeed to permit the contractor to recover judgment for sums withheld when his own default causes stop notices to be filed and the sums to be withheld by the City.
In a situation such as this where a default in the contractor's obligations to its subcontractors and other suppliers of labor or materials occurs and triggers the assignment, the contractor and the stop notice claimants have adverse interests. Therefore, the contractor does not "stand in the shoes" of the subcontractors or the suppliers of labor or materials for the purpose of seeking recovery of the funds.[1]
*1448 Accordingly, it was improper for the trial court to have awarded $13,975.84 of the judgment for the recovery of the amounts paid to Surety by the City.
The judgment is modified to eliminate from the money judgment award to contractor the sum of $13,975.84 and as so modified the judgment is affirmed. Each party shall bear its own costs on appeal.
Woolpert, Acting P.J., and Ballantyne, J., concurred.
NOTES
[*]   Pursuant to California Rules of Court, rule 976.1, this opinion is certified for publication with the exceptions of the Discussion and parts I through IV.
[*]   Retired Presiding Justice of the Court of Appeal sitting under assignment by the Chairperson of the Judicial Council.
[*]   See footnote, ante, page 1442.
[1]  Should the stop notice claimants sue contractor, contractor would be entitled to indemnification from the City for any sums the City withheld pursuant to stop notices but had not paid to the stop notice claimants.
