                      FOR PUBLICATION
  UNITED STATES COURT OF APPEALS
       FOR THE NINTH CIRCUIT

In re: STRAIGHTLINE INVESTMENTS,              
INC.,
                           Debtor,
                                                     No. 05-15979

CHARLES D. AALFS,                                     BAP No.
                                                   NC-04-01497-PSBr
                               Appellant,
                                                      OPINION
                 v.
ANDREA    WIRUM, Trustee,*
                                 Appellee.
                                              
               Appeal from the Ninth Circuit
                 Bankruptcy Appellate Panel
    Barr, Smith, and Perris, Bankruptcy Judges, Presiding

                     Argued and Submitted
           April 17, 2007—San Francisco, California

                          Filed May 8, 2008

    Before: David R. Thompson, Andrew J. Kleinfeld, and
             Sidney R. Thomas, Circuit Judges.

                    Opinion by Judge Thompson



   *During proceedings in the bankruptcy court, Charles E. Sims served as
the trustee and Plaintiff in this action. After Sims’s death, Andrea Wirum
was appointed by the bankruptcy court to replace Sims as the trustee. She
has also been substituted as the Appellee in this proceeding. Aalfs v. Sims
(In re Straightline Invs., Inc.), No. 05-15979 (9th Cir. Apr. 4, 2007) (order
substituting Appellee).

                                   5061
             IN RE STRAIGHTLINE INVESTMENTS, INC.         5065


                         COUNSEL

Philip M. Arnot, Stephen P. Arnot, The Arnot Law Firm,
Eureka, California, for the appellant.

David N. Chandler, Sr., David N. Chandler, Jr., Santa Rosa,
California, for the appellee.


                         OPINION

THOMPSON, Senior Circuit Judge:

   Appellant Charles D. Aalfs (“Aalfs”) appeals a decision by
the Ninth Circuit Bankruptcy Appellate Panel (“BAP”)
affirming the bankruptcy court’s judgment under 11 U.S.C.
§ 549(a) avoiding the transfer to Aalfs of Straightline Invest-
ments, Inc.’s (“Debtor” or “Straightline”) accounts receivable
which had a face value of approximately $200,600. In avoid-
ing the transfer, the bankruptcy court ordered Aalfs to pay the
Straightline trustee $163,007, the amount collected by Aalfs
5066          IN RE STRAIGHTLINE INVESTMENTS, INC.
on the transferred accounts, and to transfer back to the trustee
all uncollected accounts receivable still in Aalfs’s possession.

   On appeal, Aalfs contends that the transfer of accounts
receivable was not an avoidable transfer under 11 U.S.C.
§ 549(a) because there was no depletion or diminution of the
Debtor’s estate. Aalfs paid Straightline $186,455 for the
accounts. Aalfs argues that the transfer was an outright sale
of receivables in the ordinary course of business, and the
defenses of recoupment and earmarking should apply to bar
recovery by the trustee. Aalfs also argues that, even if the
transfer was avoidable, the bankruptcy court awarded the
wrong measure of recovery to the trustee under 11 U.S.C.
§ 550. We have jurisdiction pursuant to 28 U.S.C. § 158(d),
and we affirm both the bankruptcy court’s judgment and the
BAP’s decision upholding that judgment.

                    I.   BACKGROUND

   Straightline was initially in the business of leasing commer-
cial property. In 1997, it began operating a sawmill and
engaging in custom lumber milling, kiln drying of lumber,
and log cutting. On September 10, 1997, it filed a Chapter 11
bankruptcy petition. On September 11, 1997, Straightline’s
president, Matthew Galt, executed an agreement “personally
guarantee[ing Aalfs] against all losses from any lending
[Aalfs] may do to SLI [Straightline Investments, Inc.] . . . .”
On October 20, 1997, Straightline filed a motion in the bank-
ruptcy court seeking to borrow up to $500,000 from Aalfs
pursuant to 11 U.S.C. § 364(c). The bankruptcy court autho-
rized Straightline to borrow up to $100,000 from Aalfs, with
the loan secured only by a junior lien on Straightline’s equip-
ment and a senior lien on Straightline’s inventory. The bank-
ruptcy court specifically denied requests to authorize any
further borrowing, including loans secured by Straightline’s
accounts receivable.
                 IN RE STRAIGHTLINE INVESTMENTS, INC.                   5067
   Despite this order of the bankruptcy court, beginning on
September 30, 1997, and continuing through March 9, 1998,
Aalfs advanced money to Straightline in exchange for
accounts receivable. Aalfs obtained a discount from Straight-
line, paying a total of $186,455 for the accounts, while the
total face value of those accounts was approximately
$200,600. Aalfs collected only $163,007 from the accounts.
In his testimony before the bankruptcy court, Aalfs referred
to this arrangement with Straightline as a “factoring” transac-
tion.1

  In April 1998, a Chapter 11 trustee was appointed for
Straightline, and the case was converted to a Chapter 7 pro-
ceeding. The trustee learned of the postpetition transfers of
accounts receivable to Aalfs and filed the complaint in this
action to avoid those transactions.

   The bankruptcy court held a hearing on the trustee’s com-
plaint and issued its memorandum decision granting avoid-
ance of the transfers of the accounts receivable. The BAP
affirmed the bankruptcy court’s decision, and Aalfs filed a
notice of appeal to this court. We initially remanded the case
to the bankruptcy court, concluding that the appeal was inter-
locutory because the bankruptcy court had not yet decided the
  1
    “Factoring is . . . the sale of accounts receivable of a firm to a factor
at a discounted price. In return for selling the accounts receivable at a dis-
counted price, the seller receives two immediate advantages: (1) immedi-
ate access to cash; and (2) the factor assumes the risk of loss.” French v.
Philip Servs. Corp. (In re Metro. Envtl., Inc.), 293 B.R. 893, 895 (Bankr.
N.D. Ohio 2003) (internal citations and quotation marks omitted). The risk
of loss in this case may not have fallen squarely on the factor’s (Aalfs’s)
shoulders, however, because Straightline’s president “personally gua-
rantee[d Aalfs] against all losses from any lending” to Straightline. Factor-
ing can be accomplished either by an actual sale of accounts or through
their assignment. Id. at 896; see also Dobin v. Presidential Fin. Corp. of
Del. Valley (In re Cybridge Corp.), 312 B.R. 262, 265 (D.N.J. 2004)
(describing “what is commonly known as a ‘factoring’ agreement” as a
situation where one party advances a loan to the other for a security inter-
est in the other party’s accounts receivable).
5068          IN RE STRAIGHTLINE INVESTMENTS, INC.
trustee’s second cause of action regarding avoidance of a
postpetition transfer of logs. Aalfs v. Sims (In re Straightline
Invs., Inc.), 97 F. App’x 79, 79-80 (9th Cir. 2004). On
remand, the bankruptcy court entered the same judgment on
the accounts receivable claim and denied all of the trustee’s
other claims. Aalfs again appealed to the BAP, the BAP
affirmed the judgment of the bankruptcy court, and this
appeal followed.

                      II.   DISCUSSION

   We review decisions of the BAP de novo. Price v. U.S. Tr.
(In re Price), 353 F.3d 1135, 1138 (9th Cir. 2004) (citing
Hanf v. Summers (In re Summers), 332 F.3d 1240, 1242 (9th
Cir. 2003)). The bankruptcy court’s conclusions of law are
reviewed de novo, and its findings of fact are reviewed for
clear error. Id. “ ‘Under this standard, we accept findings of
fact made by the bankruptcy court unless these findings leave
the definite and firm conviction that a mistake has been com-
mitted by the bankruptcy judge.’ ” Rains v. Flinn (In re
Rains), 428 F.3d 893, 900 (9th Cir. 2005) (quoting Latman v.
Burdette, 366 F.3d 774, 781 (9th Cir. 2004)).

  A.   Avoidable Transfer Pursuant to 11 U.S.C. § 549

   [1] Under 11 U.S.C. § 549, a trustee may “avoid a transfer
of property of the estate — (1) that occurs after the com-
mencement of the case; and . . . (2) . . . (B) that is not autho-
rized under this title or by the court.” 11 U.S.C. § 549(a)(1),
(2)(B) (West 2004). “If a trustee seeks to recover a postpeti-
tion transfer under section 549, . . . . the trustee must show
that a transfer occurred after the filing of the bankruptcy peti-
tion and that the transfer was not authorized by either the
bankruptcy court or the [Bankruptcy] Code.” Mora v. Vasquez
(In re Mora), 199 F.3d 1024, 1026 (9th Cir. 1999) (citations
omitted).

 [2] “A ‘transfer’ is broadly defined by the Code as ‘every
mode, direct or indirect, absolute or conditional, voluntary or
              IN RE STRAIGHTLINE INVESTMENTS, INC.           5069
involuntary, of disposing of or parting with property or with
an interest in property . . . .’ ” Id. (quoting 11 U.S.C.
§ 101(54) (1994)). Therefore, regardless of whether we char-
acterize the transaction between Straightline and Aalfs as a
sale or a loan, it constituted a “transfer” under the Bankruptcy
Code.

   [3] Aalfs argues, however, that Straightline had no control
over the money which might be collected from the accounts
receivable, and therefore, its transfer of the accounts to Aalfs
was not a transfer of estate property. In making this argument,
Aalfs fails to recognize the difference between the accounts
receivable themselves and the funds paid by the account debt-
ors. It is the transfer of the accounts that is at issue here. Cf.
Tavormina v. Capital Factors, Inc. (In re: Jarax Int’l, Inc.),
164 B.R. 180, 182-83, 186 (Bankr. S.D. Fla. 1993) (finding
“no transfer of an interest of the [debtor] in property [under
§ 549] because the [debtor] lacked the requisite control over
the funds” where the debtor and defendants had entered into
a factoring agreement prior to the filing of a bankruptcy peti-
tion). Here, Straightline had a legal interest in its accounts
receivable in the form of a right to collect them when it trans-
ferred them to Aalfs. See In re Metro. Envtl., Inc., 293 B.R.
at 899. Therefore, “a transfer of property of the estate”
occurred. See 11 U.S.C. § 549(a).

   [4] The transfers occurred after the commencement of the
bankruptcy case, beginning on September 30, 1997, nineteen
days after Straightline filed its Chapter 11 bankruptcy peti-
tion. The trustee also established that the transfer of accounts
receivable from Straightline to Aalfs was not authorized by
the bankruptcy court. See 11 U.S.C. § 549(a)(2)(B). The
bankruptcy court’s authorization for a $100,000 loan from
Aalfs to Straightline did not include permission to transfer
any of Straightline’s accounts receivable to Aalfs. Aalfs con-
ceded as much in his testimony before the bankruptcy court.

   Aalfs argues that Straightline’s transfer of the accounts
receivable to him is not avoidable under § 549 because the
5070          IN RE STRAIGHTLINE INVESTMENTS, INC.
transfers were outright sales of the accounts which were con-
ducted in the ordinary course of Straightline’s business, and
such sales are allowed under 11 U.S.C. § 363(c). Before
addressing this argument, we first consider Aalfs’s contention
that the transfer of accounts receivable did not result in a
depletion or diminution of Straightline’s estate and therefore
cannot constitute an avoidable transfer under § 549.

  B.   Depletion or Diminution of the Estate

   Of the three cases cited by Aalfs in support of his estate
depletion argument, only one of them tends to help him, and
that is the In re Cassis decision from the Northern District of
Iowa, in which the court stated: “There must be a depletion
of the estate for there to be an avoidable transfer under § 548
or § 549.” Cambridge Tempositions, Inc. v. Cassis (In re Cas-
sis), 220 B.R. 979, 983 (Bankr. N.D. Iowa 1998) (citing In re
Jarax Int’l, Inc., 164 B.R. at 185). But neither In re Cassis nor
In re Jarax applied the depletion of the estate proposition to
a claim of an avoidable postpetition transfer under § 549.
Instead, In re Cassis dealt with a complaint to avoid a fraudu-
lent transfer under § 548, and the court in In re Jarax only
discussed depletion of the estate in the context of prepetition
preferential transfers under § 547 and fraudulent transfers
under § 548, not postpetition transfers under § 549. In re Cas-
sis, 220 B.R. at 982; In re Jarax Int’l, Inc., 164 B.R. at 185-
87; see also Adams v. Anderson (In re Superior Stamp & Coin
Co., Inc.), 223 F.3d 1004, 1007 (9th Cir. 2000) (applying the
“diminution of estate” doctrine to determine whether trans-
ferred property belongs to the debtor for purposes of § 547).
The third case cited by Aalfs — In re Bame — simply held
that the trustee was not entitled to a money judgment for an
avoidable postpetition transfer because there was no proof
that the estate suffered damages on account of the defendant’s
actions. Ramette v. Al & Alma’s Supper Club Corp. (In re
Bame), 252 B.R. 148, 162 (Bankr. D. Minn. 2000).

  [5] The question whether depletion of the estate is a
requirement for finding a transfer avoidable under § 549 is an
              IN RE STRAIGHTLINE INVESTMENTS, INC.          5071
open question in this circuit. Although the diminution of
estate theory is commonly viewed as a prerequisite for avoi-
dability of prepetition preferential transfers under 11 U.S.C.
§ 547 and fraudulent transfers under 11 U.S.C. § 548, see In
re Superior Stamp & Coin Co., Inc., 223 F.3d at 1007; In re
Smith, 966 F.2d 1527, 1535-36 (7th Cir. 1992); Nordberg v.
Sanchez (In re Chase & Sanborn Corp.), 813 F.2d 1177, 1181
(11th Cir. 1987); Deel Rent-A-Car, Inc. v. Levine, 721 F.2d
750, 755-56 (11th Cir. 1983); In re Cassis, 220 B.R. at 982;
In re Jarax, 164 B.R. at 185-87, only the Sixth Circuit has
considered the diminution of estate doctrine in a case involv-
ing the avoidance of a post-petition transfer under § 549. See
Peoples Bank & Trust Co. v. Burns (In re Shelton); 244 F.
App’x 634 (6th Cir. 2007). In that case, the Sixth Circuit
stated that the doctrine of “earmarking” was inapplicable.
However, in an earlier decision in the same case the appellate
panel had indicated that “earmarking” might apply if the
transaction in question did “not result in a diminution of the
estate’s value.” Id. at 637 (citing the panel’s earlier decision,
Peoples Bank & Trust Co. v. Burns (In re Shelton) 95 F.
App’x 801, 804 (6th Cir. 2004)). When the case came back
after remand, the court stated the question was whether it
should reconsider its earlier decision. Id. at 638. The court
decided it had no basis to do so because the parties had stipu-
lated there had been no diminution of the bankruptcy estate
and thus there would be no “manifest injustice” by letting the
earlier decision stand, even though it contained an erroneous
resolution of the “earmarking” question. Id. at 639.

   [6] We decline to expand the diminution of estate doctrine,
from its established application in § 547 and § 548 cases, to
this § 549 case. Although the primary purpose of 11 U.S.C.
§ 549 is to allow the trustee to avoid post-petition transfers of
property which deplete the estate, see 5 Lawrence P. King,
Collier on Bankruptcy § 549.02 (15th ed. 2005), the plaintiff’s
failure to demonstrate a measurable depletion of the estate is
not enough to allow a transfer to stand when it is otherwise
5072            IN RE STRAIGHTLINE INVESTMENTS, INC.
avoidable under § 549 because it satisfies all of the explicit
requirements of an avoidable postpetition transfer.2

  C.    Ordinary Course of Business

   Aalfs also argues that the transfer to him of Straightline’s
accounts receivable falls within the “ordinary course of busi-
ness” exception to avoidable postpetition transfers under 11
U.S.C. § 363(c). Section 363(c)(1) of the Bankruptcy Code
provides that “[i]f the business of the debtor is authorized to
be operated under section . . . 1108 . . . of this title and unless
the court orders otherwise, the trustee may enter into transac-
tions . . . in the ordinary course of business, without notice or
a hearing . . . .” 11 U.S.C. § 363(c)(1) (West 2004). Section
1108 permits a trustee to operate a debtor’s business unless
the bankruptcy court orders otherwise. Id. § 1108. Addition-
ally, 11 U.S.C. § 1107 grants a debtor-in-possession under
Chapter 11 all of the same rights and powers as a trustee. Id.
§ 1107(a). “A determination of whether a transaction falls
outside the ordinary course of business is a question of fact
that depends on the nature of industry practice.” Ganis Credit
Corp. v. Anderson (In re Jan Weilert RV, Inc.), 315 F.3d
1192, 1196 (9th Cir. 2003) (citing Arrow Elecs., Inc. v. Justus
(In re Kaypro), 218 F.3d 1070, 1073 (9th Cir. 2000)).

   [7] Two tests have emerged for determining whether a
transaction is within the ordinary course of business for pur-
poses of § 363(c) — the vertical dimension, or creditor’s
expectation, test, and the horizontal dimension test. Burling-
  2
   In the present case, the trustee may have shown there was a depletion
of the estate because cash worth only $186,455 was substituted for
accounts receivable with a face value of approximately $200,600, leaving
the estate with a diminished overall asset total. Although Aalfs only recov-
ered $163,007 from the accounts he obtained, we do not know whether a
greater amount could have been recovered had Straightline, rather than
Aalfs, been the entity seeking payment. But see In re Cybridge Corp., 312
B.R. at 271 (“[A]ccounts [receivable] are only valuable once they are
reduced to cash (which . . . is what [the transferee] did with them).”).
              IN RE STRAIGHTLINE INVESTMENTS, INC.           5073
ton N. R.R. Co. v. Dant & Russell, Inc. (In re Dant & Russell,
Inc.), 853 F.2d 700, 704 (9th Cir. 1988). If both tests are satis-
fied, the court must conclude that the challenged transaction
occurred in the debtor’s ordinary course of business. Id. at
705; see also Credit Alliance Corp. v. Idaho Asphalt Supply,
Inc. (In re Blumer), 95 B.R. 143, 147 & n.4 (B.A.P. 9th Cir.
1988) (stating that “the Ninth Circuit has determined that a
transaction which meets both the ‘horizontal’ and ‘vertical’
dimension tests is in the ordinary course of business[,]” but
“[i]t is unclear whether Dant & Russell requires both the ‘hor-
izontal’ and ‘vertical’ dimension tests to be satisfied”); In re
Media Cent., Inc., 115 B.R. 119, 124 (Bankr. E.D. Tenn.
1990) (“If either test or dimension is not satisfied, most likely
the disputed transaction is not in the ordinary course of busi-
ness.”).

    1. Vertical Test

   [8] “The vertical dimension, or creditor’s expectation test,
views the disputed transaction ‘from the vantage point of a
hypothetical creditor and inquires whether the transaction
subjects a creditor to economic risks of a nature different from
those he accepted when he decided to extend credit.’ ” In re
Dant & Russell, Inc., 853 F.2d at 705 (quoting Comm. of
Asbestos-Related Litigants v. Johns-Manville Corp. (In re
Johns-Manville Corp.), 60 B.R. 612, 616 (Bankr. S.D.N.Y.
1986)). In determining whether the transaction meets the ver-
tical dimension test, courts often look to the debtor’s prepeti-
tion business practices. Id. at 705 n.7. This conduct is then
compared to the debtor’s postpetition business activities. In re
Johns-Manville Corp., 60 B.R. at 617. Stated differently,
“[t]he vertical component necessarily includes an examination
of the pre-petition relationship between the debtor and his
creditors to determine whether the transaction in question was
ordinary in the context of that relationship.” Poff v. Poff Con-
str., Inc. (In re Poff Constr., Inc.), 141 B.R. 104, 106 (W.D.
Va. 1991).
5074          IN RE STRAIGHTLINE INVESTMENTS, INC.
   It is difficult to make a fair comparison of the Debtor’s
business activities before and after its filing for bankruptcy
because Straightline only entered the custom milling business
a few months before filing its bankruptcy petition. Before
that, it was in the business of leasing commercial real estate.
There were no accounts receivable transferred from Straight-
line to Aalfs before September 10, 1997, the date that Straigh-
tline filed its Chapter 11 petition. Straightline’s president,
Matthew Galt, testified that when Straightline was in the cus-
tom milling business prior to filing its Chapter 11 petition, it
often sold accounts receivable to its vendors, but the most
common aspect of these “sales” was a prepaid discount of the
customer’s accounts, rather than actual sales of the accounts
to third parties.

   Straightline’s predecessor in the custom milling business,
North Coast Hardwoods, had obtained loans from Six Rivers
Bank, and those loans were partially secured by accounts
receivable. Straightline had also obtained a loan from Six Riv-
ers Bank, but it was secured only by real estate. Six Rivers
Bank’s senior vice president, Evelyn Giddings, testified that
she would not have expected Straightline to sell its accounts
receivable at the time it obtained a loan, but at that time,
Straightline was still only in the business of leasing real
estate, and it had no accounts receivable.

   [9] The bankruptcy court found that, even if the transfer of
Straightline’s accounts receivable to Aalfs was a true sale and
not part of a disguised loan transaction, it was not accom-
plished in the ordinary course of business because Straight-
line’s creditors would have expected notice and a hearing
before such transactions occurred. That was because the bank-
ruptcy court had previously been asked to rule on the possibil-
ity of Straightline obtaining a loan using its accounts
receivable as collateral, and that request had been denied. The
bankruptcy court found that “[c]reditors would have reason-
ably expected that from that time forward they would be
              IN RE STRAIGHTLINE INVESTMENTS, INC.          5075
given notice of any attempt to transfer the receivables.” That
finding is not clearly erroneous.

   [10] Nor was the bankruptcy court clearly erroneous in its
finding that the “sales” of accounts receivable to Aalfs were
actually part of a disguised loan transaction. Aalfs had been
given Matthew Galt’s personal guarantee of full repayment,
and in correspondence between employees of Straightline and
Aalfs there were references to Aalfs’s payments for the
accounts as “advances.” See Fireman’s Fund Ins. Cos. v. Gro-
ver (In re The Woodson Co.), 813 F.2d 266, 271-72 (9th Cir.
1987) (stating that guarantee against risk of loss is a feature
that “seems to result in a finding of a debtor-creditor relation-
ship in most cases” and noting that “[l]abels cannot change
the true nature of the underlying transactions”); NetBank, FSB
v. Kipperman (In re Commercial Money Ctr., Inc.), 350 B.R.
465, 474 (B.A.P. 9th Cir. 2006) (stating that “the bankruptcy
court’s decision on the loan versus sale issue . . . is a factual
determination that we review for clear error”). We conclude
that the vertical dimension test is not satisfied.

    2.   Horizontal Test

   [11] Under the horizontal dimension test, the question is
“whether the postpetition transaction is of a type that other
similar businesses would engage in as ordinary business.” In
re Dant & Russell, Inc., 853 F.2d at 704 (citations omitted).
For example, “raising a crop would not be in the ordinary
course of business for a widget manufacturer because that is
not a widget manufacturer’s ordinary business.” Johnston v.
First St. Cos. (In re Waterfront Cos., Inc.), 56 B.R. 31, 35
(Bankr. D. Minn. 1985). The purpose of the horizontal test is
“ ‘to assure that neither the debtor nor the creditor [did] any-
thing abnormal to gain an advantage over other creditors
. . . .’ ” In re Dant & Russell, Inc., 853 F.2d at 704 (quoting
In re Johns-Manville Corp., 60 B.R. at 618).

  [12] In determining whether a challenged transaction is
ordinary for the industry, it may be helpful to compare the
5076          IN RE STRAIGHTLINE INVESTMENTS, INC.
debtor’s activities to the activities of its predecessor in busi-
ness. See id. at 705. Aalfs argues that Straightline’s own wit-
ness, Evelyn Giddings of Six Rivers Bank, testified that
factoring was common for financially distressed and startup
businesses. But Giddings’s testimony was equivocal on the
subject. She testified that Six Rivers Bank engaged in both
lending against and purchasing accounts receivable from vari-
ous entities, but she did not know if such transactions were
ordinarily entered into in the custom milling industry. The
common thread in Giddings’s testimony was that companies
who entered into factoring agreements were usually in finan-
cial straits when they did so. In addition, Aalfs admitted it
was not particularly common for businesses to sell their
accounts receivable outright, as opposed to obtaining a gen-
eral accounts receivable line of credit.

   [13] We conclude that Aalfs failed to show that the sale of
accounts receivable by a custom milling business was the type
of transaction “that other similar businesses would engage in
as ordinary business.” Id. at 704; see Fed. R. Bankr. P. 6001
(West 2005) (placing the burden of proof on the entity assert-
ing the validity of a postpetition transfer under § 549). As for
Straightline’s predecessor in the custom milling business,
North Coast Hardwoods, that entity did not sell its accounts
receivable outright; instead, it obtained a line of credit
through Six Rivers Bank which it secured by its receivables.

   [14] The sale of Straightline’s accounts receivable did not
satisfy the horizontal dimension test for sales in the ordinary
course of business under 11 U.S.C. § 363(c)(1). Even if using
accounts receivable as security for loans was common in
Straightline’s industry, any loan from Aalfs to Straightline
above $100,000 and any loan secured by collateral other than
Straightline’s equipment and inventory would have violated
the bankruptcy court’s order and would have been avoidable
and invalid on that basis. See 11 U.S.C. § 363(c)(1) (allowing
the trustee to “enter into transactions . . . in the ordinary
               IN RE STRAIGHTLINE INVESTMENTS, INC.          5077
course of business,” “unless the court orders otherwise”)
(emphasis added).

  D.     Defenses Asserted by Aalfs

  Aalfs raises the defenses of earmarking and recoupment.
For the reasons hereafter stated, he is not entitled to either
defense.

    1.    Earmarking

   [15] “[T]he earmarking doctrine applies ‘when a third party
lends money to a debtor for the specific purpose of paying a
selected creditor.’ ” In re Superior Stamp & Coin Co., Inc.,
223 F.3d at 1008 (quoting Hansen v. MacDonald Meat Co.
(In re Kemp Pac. Fisheries, Inc.), 16 F.3d 313, 316 (9th Cir.
1994)).

    [T]he earmarking doctrine requires: “(1) the exis-
    tence of an agreement between the new lender and
    the debtor that the new funds will be used to pay a
    specified antecedent debt; (2) performance of that
    agreement according to its terms; (3) the transaction
    viewed as a whole . . . does not result in any diminu-
    tion of the estate.”

Id. (quoting McCuskey v. Nat’l Bank of Waterloo (In re Boh-
len Enters., Ltd.), 859 F.2d 561, 566 (8th Cir. 1988)).

   [16] Here, Aalfs paid money to Straightline in exchange for
Straighline’s accounts receivable. Aalfs contends he was not
a “lender,” but even if he were, the money he paid was not
paid under any agreement that it would be used to pay a spe-
cific debt. Nor was there any showing as to how the money
Aalfs paid was used by Straightline. And, as previously
stated, there arguably was a diminution in the value of
Straightline’s estate because of the discount at which its
receivables were sold to Aalfs.
5078          IN RE STRAIGHTLINE INVESTMENTS, INC.
   [17] Because the requirements of the earmarking doctrine
are not satisfied, the defense of earmarking does not apply.

    2.   Recoupment

   “The doctrine[ ] of . . . recoupment [is] equitable in nature,
and [its] use by the bankruptcy court is permissive [and]
reviewed for an abuse of discretion.” Oregon v. Harmon (In
re Harmon), 188 B.R. 421, 424 (B.A.P. 9th Cir. 1995) (citing
Pieri v. Lysenko (In re Pieri), 86 B.R. 208, 210 (B.A.P. 9th
Cir. 1988)).

   [18] “Recoupment . . . involves a netting out of debt arising
from a single transaction.” Id. at 425. “ ‘Its function is to
reduce the amount demanded, but only to the extent of the
plaintiff’s claim.’ ” Id. (quoting Long Term Disability Plan of
Hoffman-La Roche, Inc. v. Hiler (In re Hiler), 99 B.R. 238,
243 (Bankr. D.N.J. 1989)). “[R]ecoupment ‘is the setting up
of a demand arising from the same transaction as the plain-
tiff’s claim or cause of action, strictly for the purpose of
abatement or reduction of such claim.’ ” Newbery Corp. v.
Fireman’s Fund Ins. Co., 95 F.3d 1392, 1399 (9th Cir. 1996)
(quoting 5 Collier on Bankruptcy ¶ 553.03, at 553-15 (15th
ed. 1984)).

   Aalfs paid $186,455 for receivables having a face value of
approximately $200,600. Aalfs argues that the trustee’s recov-
ery in this case should be subject to his right to recoup the
$186,455 he paid for the accounts in the first place. In Aalfs’s
opinion, in keeping with the equitable principle of recoup-
ment, the trustee should recover nothing because the amount
the estate already received is greater than the dollar amount
of damages the bankruptcy court awarded to the trustee.

   [19] The doctrine of recoupment does not apply here, how-
ever, because it is an equitable remedy and equitable remedies
may not be invoked to compensate someone who has engaged
in inequitable conduct. Aalfs and Galt essentially effected a
              IN RE STRAIGHTLINE INVESTMENTS, INC.         5079
transfer of Straightline’s accounts receivable to Aalfs in con-
travention of the bankruptcy court’s order prohibiting such a
transfer. They contend that the transaction was a sale in the
ordinary course of business, notwithstanding that Aalfs
advanced the money to Straightline for the accounts under an
agreement with Galt that he would be repaid in full. That was
a disguised loan which the bankruptcy court had precluded,
yet Aalfs went ahead with it anyway. Aalfs engaged in inequi-
table conduct, and he is not entitled to the equitable remedy
of recoupment. See United States v. Arkison (In re Cascade
Rds., Inc.), 34 F.3d 756, 762 (9th Cir. 1994) (affirming bank-
ruptcy court’s conclusion that equitable principle was not
available to party who engaged in inequitable conduct).

  E. Appropriate Measure of Recovery Under 11 U.S.C.
  § 550

   “The bankruptcy court’s choice of remedies is reviewed for
an abuse of discretion.” Bankr. Receivables Mgmt. v. Lopez
(In re Lopez), 345 F.3d 701, 705 (9th Cir. 2003) (citing Stone
v. San Francisco, 968 F.2d 850, 861 (9th Cir. 1992)). Section
550(a) of the Bankruptcy Code provides that “to the extent
that a transfer is avoided under section . . . 549 . . . , the
trustee may recover, for the benefit of the estate, the property
transferred, or, if the court so orders, the value of such prop-
erty, from— (1) the initial transferee of such transfer . . . .”
11 U.S.C. § 550(a) (West 2004).

   The bankruptcy court entered judgment against Aalfs in the
amount of $163,007 — the amount he collected from the
accounts receivables — plus interest, costs, and the return of
the remainder of the uncollected accounts. Aalfs contends this
resulted in a windfall to the Debtor’s estate because the
Debtor had already received the $186,455 that Aalfs paid for
the accounts.

   [20] Section 550 provides for recovery of the property
transferred and avoided under § 549 or for recovery of the
5080             IN RE STRAIGHTLINE INVESTMENTS, INC.
value of that property. Id. By awarding the trustee the sum of
what Aalfs collected on the accounts plus the uncollected
accounts, the bankruptcy court ordered a monetary recovery
for part of the value of the improperly transferred property
and ordered the return of the remainder of the uncollected
accounts.3 The BAP affirmed this award, but the dissenting
BAP judge believed the trustee should only have been
allowed to recover the amount to which Straightline’s estate
was damaged — the difference between the $200,600 face
value of accounts receivable transferred to Aalfs and the
$186,455 Straightline received from Aalfs.

   [21] Generally, the purpose of § 550(a) is “ ‘to restore the
estate to the financial condition it would have enjoyed if the
transfer had not occurred.’ ” Acequia, Inc. v. Clinton (In re
Acequia, Inc.), 34 F.3d 800, 812 (quoting Morris v. Kan. Dry-
wall Supply Co. (In re Classic Drywall, Inc.), 127 B.R. 874,
876 (D. Kan. 1991)). Aalfs and the dissenting BAP judge con-
tend that if the recovery awarded to the estate under § 550(a)
results in the estate being any better off financially than it was
prior to the avoidable transfer, the recovery would be
improper because the estate would receive a “windfall.”

   There is some caselaw to support this view. In In re
Cybridge Corp., a bankruptcy court in New Jersey held that
although the postpetition transfer of accounts receivable from
the debtor was avoidable under § 549, the transferee was enti-
tled to a credit for property already returned to the estate
where the transferee had advanced funds to the debtor in
exchange for a security interest in the debtor’s accounts
receivable, the transferee had collected less money from the
  3
   Although the statute contains the conjunction “or,” at least one court
has held that the remedies of the value of the property or the property itself
are not mutually exclusive, and the bankruptcy court may award a judg-
ment that involves both types of recovery, as long as it does not result in
double recovery for the estate. Feltman v. Warmus (In re Am. Way Serv.
Corp.), 229 B.R. 496, 531 (Bankr. S.D. Fla. 1999) (citing 11 U.S.C.
§§ 102(5), 550(a), (d)).
              IN RE STRAIGHTLINE INVESTMENTS, INC.          5081
receivables than it had advanced, and the transferee had no
knowledge of the bankruptcy proceeding until after its
advancement of cash. In re Cybridge Corp., 312 B.R. at 265,
269, 272. The New Jersey court based its conclusion on
§ 550(d)’s limitation of recovery to “a single satisfaction” and
on the permission granted bankruptcy courts pursuant to 11
U.S.C. § 105(a) to issue equitable orders not violative of other
code provisions. In re Cybridge Corp., 312 B.R. at 268-69.
Central to its analysis under both subsections were consider-
ations of equity. The court expressed concern that if the
trustee were permitted to recover the cash collected on the
accounts receivable in addition to the money paid by the
transferee for a security interest in those accounts, this would
encourage debtors to take advantage of “unsuspecting credi-
tors” by continuing to enter factoring agreements after the fil-
ing of a bankruptcy petition, failing to tell the creditors about
the bankruptcy case, and later recovering the funds collected
by the innocent creditors. Id. at 270.

   A recent decision of the Bankruptcy Court for the Southern
District of Florida on this issue was also influenced by con-
cerns regarding equity. See Bakst v. Sawran (In re Sawran),
359 B.R. 348 (Bankr. S.D. Fla. 2007). The bankruptcy court
there held that the defendants were entitled to an equitable
credit for the amount of prepetition cash transfers made to the
debtor because the court found that they were “innocent of
wrongdoing and deserve[d] protection under the[ ] circum-
stances.” Id. at 354. Also important to the bankruptcy court’s
holding in In re Sawran was its finding that the defendants
“were not motivated by personal gain . . . .” Id.

   [22] The situation here is different. Aalfs was fully aware
of Straightline’s bankruptcy petition when he advanced funds
to Straightline in exchange for the accounts receivable. Aalfs
was no “unsuspecting creditor.” Even the Acequia case relied
on by Aalfs held that requiring the return of the wrongfully-
transferred property to the estate was the proper course of
action where the debtor had a greater equitable claim to the
5082          IN RE STRAIGHTLINE INVESTMENTS, INC.
property than did the transferee. In re Acequia, Inc., 34 F.3d
at 812 (“[E]ven if the recovery did constitute a ‘windfall,’
Acequia[, the debtor,] has a greater equitable claim to the
transferred [estate] funds than does Clinton, the wrongdoer.”).
That is true here as well. Although the bankruptcy court’s
judgment may allow the Debtor’s estate theoretically to
remain $186,455 ahead of where it would have been in the
absence of any transfer, the estate has a greater equitable
claim than does Aalfs. Aalfs was fully aware that Straightline
was in bankruptcy proceedings and that the bankruptcy court
had previously denied Straightline’s request to obtain loans
secured by its accounts receivable. The uncollected accounts
and the $163,007 which he collected should be returned to the
estate for the benefit of the estate’s creditors instead of
remaining in Aalfs’s hands. It was he, after all, who joined
Straightline’s president in attempting to circumvent the bank-
ruptcy court’s order. See id. at 811 (discussing § 550(a)’s
requirement of recovery for the benefit of the estate, which
includes direct and indirect benefits to creditors).

   [23] Finally, the Ninth Circuit BAP has noted that the
Bankruptcy “Code contains no provision which would allow
[a transferee] to set off the amount he paid for the [avoidably
transferred property] against the value of the [property].”
Walsh v. Alpha Fin. Group (In re Rice), 83 B.R. 8, 13 (B.A.P.
9th Cir. 1987). That is exactly what Aalfs is attempting to do
here — set off the amount he paid for the accounts receivable
against the value of the accounts. The only exceptions to
recovery under § 550(a) are made for (1) good faith transfer-
ees who took property subsequent to the initial transferee and
(2) non-insider prepetition transferees who receive property
originally transferred for the benefit of an insider. 11 U.S.C.
§ 550(b)-(c) (West 2004). Even a good faith transferee is not
protected beyond a possible lien on the property, and he is
only protected if he is the initial transferee. Id. § 550(a)-(b),
(e). Section 550 is thus substantially less protective of trans-
ferees than it is of the estate. The bankruptcy court did not
abuse its discretion in determining that the remedy in this case
             IN RE STRAIGHTLINE INVESTMENTS, INC.        5083
should be the recovery by the trustee of the $163,007 Aalfs
collected, plus all remaining uncollected accounts. See In re
Lopez, 345 F.3d at 705 (applying abuse of discretion standard
to bankruptcy court’s choice of remedy).

                    III.   CONCLUSION

   We affirm the bankruptcy court’s avoidance of the postpeti-
tion transfer to Aalfs of Straightline’s accounts receivable
under 11 U.S.C. § 549(a), and conclude that the bankruptcy
court’s finding that the transaction was a disguised loan in
contravention of its earlier order was not clearly erroneous.
We also affirm the bankruptcy court’s decision that the trans-
fers of accounts were not conducted in the ordinary course of
Straightline’s business under 11 U.S.C. § 363(c).

   [24] The bankruptcy court did not err in rejecting Aalfs’s
asserted defenses of earmarking and recoupment because
Aalfs did not satisfy the requirements of earmarking, and his
inequitable conduct barred him from recoupment benefits.
Finally, we affirm the recovery awarded to the trustee under
11 U.S.C. § 550 as an appropriate equitable remedy.

  AFFIRMED.
