
45 Cal.App.3d 331 (1975)
119 Cal. Rptr. 370
ROBERT B. NEVIN et al., Plaintiffs, Cross-defendants and Appellants,
v.
HERMAN M. SALK et al., Defendants, Cross-complainants and Appellants.
Docket No. 13782.
Court of Appeals of California, Fourth District, Division Two.
February 14, 1975.
*334 COUNSEL
Sanders & Albertini and Lambert S. Gill for Plaintiffs, Cross-defendants and Appellants.
Sheppard, Mullin, Richter & Hampton and John A. Sturgeon for Defendants, Cross-complainants and Appellants.
OPINION
KERRIGAN, J.
In 1970, Robert B. Nevin and his wife ("Nevin") purchased the Desert Animal Hospital in Palm Springs from Herman M. *335 Salk and his wife ("Salk") for $200,000, payable $25,000 down, with the $175,000 balance represented by a $146,000 secured note and a $29,000 unsecured note. After closing escrow, taking possession, and making payments totaling $8,000 on the secured note and $4,500 on the unsecured obligation, Nevin defaulted. Salk commenced foreclosure proceedings. Nevin then sued Salk for fraud in connection with the sale, seeking rescission, restitution of monies paid ($37,500) and damages. When the court denied Nevin's application to enjoin the foreclosure proceedings, Nevin vacated the premises and took certain personal property with him. Salk countered by proceeding with foreclosure and by filing a cross-action to recover (1) the balance of principal and interest due on the unsecured note ($26,412) and (2) the value of the personal property converted by Nevin.
At the conclusion of the trial, the court made the following pertinent findings: (1) no fraud was perpetrated by the sellers in conveying the hospital; (2) the sale of the hospital constituted one transaction and one integrated contract, although several instruments were executed in connection therewith (agreement of sale, two notes, a deed of trust on real property, a security agreement and chattel mortgage, and other documents); (3) only the $146,000 note was secured; (4) the $29,000 unsecured note was given as partial consideration in connection with the sale; (5) the two notes and the deed of trust contained provisions for the payment of attorney fees to the prevailing party in the event of suit; and (6) the buyers wrongfully converted some of the seller's personal property having a value of $6,000. But the court concluded that recovery of the balance due on the unsecured note ($26,412) was barred by section 580b of the Code of Civil Procedure (the anti-deficiency statute).
Consequently, judgment was entered to the following effect: (1) Nevin take nothing by reason of his complaint (fraud); (2) Salk take nothing on his first cause of action by way of cross-complaint (the unsecured note); (3) Salk recover $6,000 on the second cause of action (conversion); and (4) Salk recover $12,500 attorney fees for successfully defending the underlying action for fraud.
Nevin appeals from that portion of the judgment awarding Salk $12,500 in attorney fees. Salk cross-appeals from that part of the judgment decreeing he was not entitled to the balance due on the $29,000 unsecured note or any fees thereon; in addition, Salk claims the $12,500 fee award was inadequate and that he is also entitled to supplemental attorney fees on appeal.
*336 Although stated in varying ways, Nevin claims that the $12,500 attorney fee award was improper because this was mainly a tort action for fraud; that the court did not rule favorably to Salk on the $29,000 unsecured note containing the attorney fee proviso; and that fees were not recoverable in connection with the $6,000 tort award for conversion.
On the other hand, Salk claims that the trial court's conclusion that the anti-deficiency statute (Code Civ. Proc., § 580b) barred recovery on the unsecured note was wrong and that $25,000 in fees should have been awarded instead of $12,500.
We have concluded that the $12,500 award was proper and reasonable for fees incurred by Salk in defending the main lawsuit (fraud). However, we have also determined that the anti-deficiency statute does not preclude Salk from recovering the balance due on the unsecured note, together with a reasonable attorney fee in connection therewith, and therefore reverse that part of the judgment decreeing that Salk take nothing on the note.

FACTS
Between 1954-1970, Salk, a veterinarian, owned and operated the Desert Animal Hospital in Palm Springs.[1] In 1970, he decided to sell the hospital and Nevin, a building contractor, indicated a desire to purchase it inasmuch as Nevin had built and owned several other animal hospitals, some of which he had sold at a profit.
Nevin had his attorney prepare a proposed agreement of sale which called for a total purchase price of $200,000 with $25,000 down and with the $175,000 balance to be represented by a note secured by deed of trust on the real property of the hospital. Upon receiving the proposal, Salk consulted his attorney and was advised that the $25,000 down payment was inadequate on a $200,000 transaction inasmuch as the real property, standing alone, would be insufficient security in the event of foreclosure. Instead, Salk's attorney made the following recommendation in letter form: that the $25,000 down payment through escrow all apply to the real estate; that a separate unsecured promissory note in the sum of $25,000 be taken back which would reduce the secured note to $150,000; and that the monthly payments could be reduced pro-rata on the large note and allotted to the $25,000 unsecured note; he also suggested that *337 the consideration for each note  the secured and unsecured  be spelled out in the agreement. Salk sent a copy of his attorney's letter containing the modified proposal to Nevin.
Nevin contacted Salk's attorney directly. During the ensuing negotiations, Salk's attorney frankly told Nevin he wanted Salk to be in a position to recover on a separate unsecured note in event of foreclosure on the real property. In turn, Nevin requested a shorter pay-off period on the unsecured note due to the personal liability he would incur on that note.
As requested by Nevin, the unsecured note was to have a faster rate of pay-off than the secured note. (In other words, the unsecured note would amortize in about six years while the secured note would amortize in about eight years.) There was also evidence that during the negotiations, Nevin stated that he wanted to obtain the maximum tax advantages possible by deducting the consideration allocated to the unsecured note from ordinary income. (This meant that Salk would have to report these payments as ordinary income instead of as a capital gain.)
As finally formalized, the agreement of sale dated June 11, 1970, stated the $175,000 balance would be represented by the $146,000 secured note and the $29,000 unsecured note. It also pro-rated the total consideration as follows:


  Drugs and supplies                        $  5,000
  Hospital fixtures and equipment              8,500
  Goodwill of Desert Animal Hospital          11,500
  Salk's promise not to compete               15,000
  Consulting services by the Salks            14,000
  Real property                              146,000
  Total Purchase Price                      $200,000

Broken down, the $29,000 unsecured note was given for Salk's promise not to compete ($15,000) and his promise to act as a consultant ($14,000). The price of the drugs, supplies, fixtures and equipment coincided with the $25,000 down payment. The $146,000 secured note represented the price of the land and improvements.

APPEAL
(1a) Reduced to the most elementary terms, Nevin's attack on the *338 $12,500 fee award takes the following form: attorney fees are only recoverable under statute or contract; the agreement of sale contained no provision for payment of fees; although the two notes provided for payment of fees, neither was in existence at the time the agreement of sale was executed; and no recovery was obtained on the unsecured note.
However, Nevin's contention ignores the fact that both notes were referred to in the agreement and that the trial court found that the notes and security agreements were incorporated in the agreement. The agreement specified that a copy of the $29,000 promissory note would be attached as an exhibit to the agreement; and the $146,000 promissory note was incorporated therein by reference. Moreover, the deed of trust provided for payment of fees if it was necessary to defend any lawsuit affecting the security or the rights of the beneficiary.
(2) Under section 1642 of the Civil Code, it is the general rule that several papers relating to the same subject matter and executed as parts of substantially one transaction, are to be construed together as one contract. (See Cadigan v. American Trust Co., 131 Cal. App.2d 780, 784 [281 P.2d 332].) Thus, a note, mortgage and agreement of sale constitute one contract where they are part of the same transaction. (See Baucum v. LeBaron, 136 Cal. App.2d 593 [289 P.2d 266].) The documents need not be executed contemporaneously; it is a question of fact as to whether several writings comprise one transaction. (Cadigan v. American Trust Co., supra, 131 Cal. App.2d 780, 786.)
(1b) Inasmuch as the provisions of the notes and the security instruments were incorporated in the agreement, and made a part thereof, and inasmuch as the sale involved one piece of property and veterinary practice, the trial court properly concluded all the instruments formed a single contract and the fact the agreement itself contained no provision for payment of fees in the event of a lawsuit is of no consequence.
Turning to the propriety of the $12,500 fee award, section 1021 of the Code of Civil Procedure provides as follows: "Except as attorney's fees are specifically provided for by statute, the measure and mode of compensation of attorneys ... is left to the agreement, express or implied, of the parties...." A provision in an agreement that one party agrees to pay another reasonable attorney fees in the event the latter prevails in litigation is valid. (Malibou Lake Mountain Club, Ltd. v. Smith, 18 Cal. App.3d 31, 35 [95 Cal. Rptr. 553].)
*339 Where the instrument so provides, attorney fees may be awarded to the holder of a deed of trust. (Hunt v. Smyth, 25 Cal. App.3d 807, 832 [101 Cal. Rptr. 4]; Shannon v. Northern Counties Title Ins. Co., 270 Cal. App.2d 686 [76 Cal. Rptr. 7].) This is true even when the adverse claim is made by the mortgagor. (Techow v. Pollack, 111 Cal. App.2d 556, 558 [244 P.2d 915].) (3) Where a party is entitled by statute or contract to attorney's fees, the amount awarded is within the discretion of the trial court. (Craw v. Craig, 168 Cal. 351, 352 [143 P. 604]; Woodward v. Brown, 119 Cal. 283, 309 [51 P. 2, 542].)
Substantial fee awards have been upheld in security transaction situations involving disputes between obligors and obligees.
In Gudel v. Ellis, 200 Cal. App.2d 849 [19 Cal. Rptr. 751], the seller had sold a piece of property to the buyer, a portion being paid down and the balance evidenced by a note secured by a trust deed; thereafter the original purchaser sold the property to a third party who assumed the note secured by deed of trust and later defaulted in the payments; the beneficiary elected to file a notice of breach and election to sell; the original buyer brought an action for a temporary restraining order and a preliminary injunction pending a determination of the amounts due under the secured note. Following a trial of the action to enjoin the trustee's sale of the real property, the trial court awarded the seller $1,750 in attorney's fees; the reviewing court held that under the obligations contained in the deed of trust, the trustor was required to pay the trustee and the beneficiary any sums incurred in protecting the security and upheld the award.
Similarly, in Techow v. Pollack, supra, 111 Cal. App.2d 556, an action was brought by the maker of a promissory note against the holder of the trust deed to determine the balance due on the note; the trial court awarded the beneficiary $1,500 and the fee was upheld on appeal.
In Hayward v. Widmann, 133 Cal. App. 184 [23 P.2d 762], plaintiff sued to recover money due on a note and to foreclose on pledged stock; defendant filed a cross-complaint for fraud in connection with the stock transaction; the note provided that in case suit was commenced to collect it, the promisee agreed to pay such additional sums as the court may find reasonable as attorney fees; the trial court found plaintiff was entitled to recover the balance due on the note and that no fraud was perpetrated in connection with the sale of the stock; the reviewing court held that a $20,000 fee award was reasonable where the trial was a lengthy one.
*340 (1c) The main action for fraud vitally affected Salk's security interests. Considerable pretrial (300-400 hours) and trial time (8 days) was expended in protecting those interests. In effect, Nevin was seeking rescission for the purpose of canceling the $146,000 note, the $29,000 note, the security interests in the chattels and real property, as well as restitution. Although the action sounded in tort (fraud), it nonetheless constituted an action affecting Salk's security interest as well as his unsecured interests. Hence, attorney's fees incurred by Salk in defending against the fraud action were compensable under the first trust deed's attorney fee provision, and the fees awarded were reasonable in view of the time expended and the results obtained.
In his final attack on the $12,500 fee award, Nevin claims that Salk was not the prevailing party. However, case law supports the award of attorney fees under a written agreement where one successfully defends against the claims for affirmative relief asserted by the other party. (Distefano v. Hall, 263 Cal. App.2d 380 [69 Cal. Rptr. 691]; Gudel v. Ellis, supra, 200 Cal. App.2d 849.)
Consequently, the court was right in awarding fees. Salk certainly prevailed on the action brought on the complaint for the purpose of canceling the note and deed of trust and the unsecured note and to cancel the agreement of sale and recover damages for fraud. That relief was denied. The prevailing party in an action for rescission is entitled to an award of attorney's fees where the contract contains a fee provision.

CROSS-APPEAL
(4a) Salk maintains the trial court erred in concluding that he was not entitled to recover the balance due on the unsecured note. Collateral thereto is the claim that the court also erred in failing to award attorney's fees on said note.
Section 580b of the Code of Civil Procedure provides in part as follows: "No deficiency judgment shall lie in any event after any sale of real property for failure of the purchaser to complete his contract of sale, or under a deed of trust, or mortgage, given to the vendor to secure payment of the balance of the purchase price of real property, ... [¶] Where both a chattel mortgage and a deed of trust ... have been given to secure payment of the balance of the combined purchase price of both *341 real and personal property, no deficiency judgment shall lie at any time under any one thereof if no deficiency judgment would lie under the deed of trust...."
(5) The principal purpose of the anti-deficiency statutes (Code Civ. Proc., §§ 580b, 580d, 726) is to discourage land sales which are unsound because the land is overvalued and, in the event of a depression in land values, to prevent the aggravation of the downturn that would result if defaulting purchasers not only lost the land but were also burdened with personal liability. (Bargioni v. Hill, 59 Cal.2d 121, 123 [28 Cal. Rptr. 321, 378 P.2d 593].) Stated in simple terms, the main goal of the Legislature in enacting and amending section 580b was to protect the ordinary buyer from personal liability when purchasing a home. (See 3 Witkin, Summary of Cal. Law (8th ed. 1973) § 121, p. 1590.)
The agreement herein set forth the exact consideration for each item sold (see discussion, infra). It allocated to the $29,000 unsecured note the purchase price of Salk's promise not to compete ($15,000) and his promise to act as a consultant ($14,000). The prices of the other items sold, including the real and personal property, were allocated to the secured note and down payment. The trial court apparently assumed that because there was only one integrated contract between the parties  a single purchase agreement  section 580b precluded recovery of any part of the purchase price. In doing so, the court erred.
In interpreting a land sales agreement, it really comes down to a question of intent; the format adopted by the parties is important primarily as the manifestation of that intent; where the purchase price is represented by different notes that are payable separately and are separately secured, that format should be honored; the form of the debt indicates their intent; if the parties express a single price by a single note or duplicate notes, they have a single debt;[2] but if they break the price into distinct amounts represented by separate notes that are independently secured or partially unsecured, they have separate debts. (6) Succinctly stated, fractionalizing a total purchase price and representing distinct parts of it by truly separate notes is proper so long *342 as the separate notes are given for unmistakably distinct purposes. (Hetland, Cal. Real Estate Secured Transactions (Cont. Ed. Bar 1970) § 6.12, pp. 246-248.)
Where fractionalizing occurs, only the secured part of the transaction is governed by section 580b. The statutes do not apply to unsecured notes (see Jonathan Manor, Inc. v. Artisan, Inc., 247 Cal. App.2d 651, 653 [56 Cal. Rptr. 14]) inasmuch as the section is limited by its express language to a contract of sale, deed of trust, or mortgage; therefore, the Legislature did not intend to prohibit the payment for real property by an unsecured note or to limit the recovery thereon. (Christopherson v. Allen, 190 Cal. App.2d 848, 851-852 [12 Cal. Rptr. 658]; see also Roseleaf Corp. v. Chierighino, 59 Cal.2d 35 [27 Cal. Rptr. 873, 378 P.2d 97].)
In Van Vleck Realty v. Gaunt, 250 Cal. App.2d 81 [58 Cal. Rptr. 246], plaintiff sold a parcel of real property for $185,000; the defendants paid for the land in the following manner: (1) by executing a $50,000 note secured by a first deed of trust in favor of a lending institution; (2) by signing a $116,000 note secured by a second deed of trust in plaintiff's favor; (3) by giving plaintiff an unsecured note for $15,000; and (4) by paying cash in the sum of $3,650; defendants defaulted on plaintiff's secured note and plaintiff accepted a deed in lieu of foreclosure on the second deed of trust; plaintiff sued to enforce the $15,000 unsecured note; the trial court found that plaintiff's note was unsecured but held that section 580b applied on the basis that the unsecured note was "part of the obligation secured" within the meaning of the statute; in reversing, the reviewing court held that under the plain language of the statute, section 580b applied only to secured notes and did not extend to unsecured notes even though given as part of the purchase price.
(4b) Salk sold the hospital and the purchase price was allocated: the $146,000 secured note represented only a part of the purchase price; the $29,000 unsecured note was a separate additional part of the price. The trial court properly found that the agreement of sale allocated the total purchase price to the items shown therein and that the $146,000 note was secured. No duplicate consideration was present with respect to the two notes since a proper allocation of the sales price was made between them. The $29,000 note covered the full price to be paid by Nevin for Salk's promise not to compete ($15,000) and for Salk's agreement to act as a consultant for seven years ($14,000). That consideration was separate and distinct from the land and the hospital.
*343 Consequently, the court made proper findings but came to an improper conclusion in ruling that 580b applied. The allocation was entirely proper. There is substantial evidence indicating that proration of the consideration was discussed prior to the transaction and that Salk's lawyer objected to the adequacy of the $25,000 down payment on a $200,000 sale and, therefore, insisted on the allocation. Nevin was fully apprised as to the reasons therefor and was explicitly told that he would be personally liable for the balance on the unsecured note. In other words, no deception nor gimmickery was employed to mislead Nevin as to the value of the land or the security nor to evade the statutory purposes. This was strictly a commercial transaction. Nevin was knowledgeable in such matters. He knew what it meant to be exposed to personal liability in the event he defaulted in the payment of the unsecured note inasmuch as he requested an accelerated maturity date on the unsecured obligation so as to reduce the length of his exposure. Moreover, he recognized the tax advantages inherent in executing the unsecured note  he could amortize the note over a six-year period and Salk would have to report the payments on the note as ordinary income. Stated summarily, this was an open, aboveboard business transaction  not a scheme to circumvent the anti-deficiency statutes.
Consequently, that portion of the judgment denying Salk recovery of the balance due on the unsecured note must be reversed.
(7a) Salk also maintains that the $12,500 fee award was unreasonable. His argument takes the following form: his attorney spent 375 hours in pretrial time, 8 full days in trial, and 100 hours in preparing findings of fact and conclusions of law and in opposing the new trial motion filed by Nevin; his attorney was entitled to $35-$55 an hour; the main action was a serious suit involving several thousands of dollars; and $25,000 would have been a reasonable fee in view of the time expended and the results obtained.
(8) Among the factors to be considered as to what constitutes a reasonable compensation for an attorney who has rendered services in connection with a legal proceeding are the nature of the litigation; its difficulty and the amount involved; the skill required and the skill employed in handling the litigation; the attention given; the success of the attorney's efforts; his learning, his age, and his experience in the particular type of work demanded; the intricacies and importance of the litigation; the labor and necessity for skilled legal training and ability in trying the cause; and the time consumed. (Shannon v. Northern Counties Title Ins. Co., supra, 270 Cal. App.2d 686, 689.)
*344 (7b) While we concede that the litigation was serious, that considerable skill was required in handling the case, and that considerable time was expended in defending and prosecuting Salk's best interests, we cannot say as a matter of law that the fee was unreasonable. In the first place, the $12,500 awarded for defending a $200,000 sale constitutes a fair sum. Second, in the event Salk contracted to pay $25,000 on an hourly basis, he is in a position to pay the balance due in view of the results obtained through his counsel's efforts; after all, he has recovered the land and the improvements and has been freed of his obligations under the contract (his agreement not to compete and to act as a consultant). Finally, on this point, Nevin has suffered enough financial detriment in this transaction, notwithstanding the fact that he wrongfully violated his promise to pay. In short, Nevin lost over $75,000 in this matter: $37,500 in payments, $26,400 on the unsecured note, and $12,500 for Salk's fees in connection with the trial of the main action.
Furthermore, the trial court denied fees for the services rendered by Salk's attorney in attempting to recover the balance due on the unsecured note. Inasmuch as a reversal of that portion of the judgment is mandated, Salk's attorney will be entitled to file an application with the trial court for the purpose of determining the additional fee to which he is entitled in connection therewith.
Similarly, Salk's counsel may also file a petition upon remand for the purpose of determining the fees to which he is entitled in connection with the appeal. If attorney's fees are awardable in the trial court, they also may be allowed on appeal. (See Hunt v. Smyth, supra, 25 Cal. App.3d 807, 836.) The trial court is in the best position to determine the amount thereof.

DISPOSITION
That portion of the judgment awarding the Salks $12,500 in attorney fees is affirmed; that part of the judgment denying the Salks any recovery on the first cause of action of the cross-complaint (the unsecured note) is reversed.
Gardner, P.J., and Tamura, J., concurred.
Petitions for a rehearing were denied March 4 and 10, 1975.
NOTES
[1]  Salk stated he also worked with his brother (Jonas) in developing the famous Salk vaccine during part of this period.
[2]  For example, if a single purchase price balance of $7,000 exists and the $7,000 is represented by separate notes, each for $7,000, one note being secured by a deed of trust upon real property and one by chattel mortgage upon the personalty sold, these duplicate notes represent the same consideration  the purchase price of the property sold; thus, section 580d of the Code of Civil Procedure bars recovery for any deficiency existing after foreclosure by power of sale of the trust deed and chattel mortgage (Freedland v. Greco, 45 Cal.2d 462 [289 P.2d 463].)
