
543 F.3d 469 (2008)
David G. VELDE, Chapter 7 Trustee, Appellant,
v.
David KIRSCH, Appellee.
No. 07-2017.
United States Court of Appeals, Eighth Circuit.
Submitted: January 16, 2008.
Filed: September 24, 2008.
*471 Justin Peter Weinberg, argued, Michael S. Dove, Mary Kay Mages, on the brief, New Ulm, MN, for appellant.
David L. Johnson, argued, Fargo ND, for appellee.
Before COLLOTON and SHEPHERD, Circuit Judges, and ERICKSON,[1] District Judge.
ERICKSON, District Judge.
David G. Velde, a bankruptcy trustee for the District of Minnesota, appeals the decision of the district court[2] reversing and vacating a prior decision of the bankruptcy court in an adversary proceeding. The trustee contends that the check received by David Kirsch in replacement of a dishonored check was a payment made within the ninety-day period prior to the filing of a bankruptcy and was thus a prohibited preference under the Bankruptcy Code § 547(b). Because the replacement check resulted in the release of Kirsch's bank's security interest in collateral, it constitutes a contemporaneous exchange for new value falling within an exception to the trustee's avoidance powers. We therefore affirm.

I.
On February 3, 2004, an involuntary Chapter 7 bankruptcy petition was filed against Daniel Miller, the owner of Danielson Grain, a crop storage elevator located in East Grand Forks, Minnesota. Miller converted the involuntary case to a Chapter 11 proceeding. On September 29, 2004, the Bankruptcy Court converted Miller's petition back to a Chapter 7 case and appointed David Velde as trustee of Miller's bankruptcy. The trustee commenced several adversary proceedings, including this case, to recover the value of checks that Miller issued during the ninety-day period prior to the bankruptcy filing. This case arises out of a $44,995.14 check Miller issued on October 27, 2003, to pay for soybeans Kirsch had previously delivered to Miller. The check was dishonored by Miller's bank. Miller replaced the dishonored check with a bank check within the ninety days prior to the original bankruptcy filing. Both checks were made payable to Kirsch and his bank. Only after receiving payment on Kirsch's replacement check did Kirsch's bank release its security interest in the soybeans.
The Trustee brought an adversarial proceeding against Kirsch asserting that the replacement check was a preferential transfer under the Bankruptcy Code. The Bankruptcy Court held that a payment to cure a dishonored check cannot be a contemporaneous exchange for value. Appeal was then taken to the district court. The court reasoned that the release of the security agreement by the bank after receipt *472 of the replacement check constituted a contemporaneous exchange for new value, and reversed. This appeal followed.

II.
The issue presented is whether a trustee may avoid a prebankruptcy transaction pursuant to 11 U.S.C. § 547 where a debtor issues a replacement check jointly payable to a creditor and its bank for a check which was previously issued and dishonored, or whether a contemporaneous exchange for value occurs when the bank releases a security interest in the debtor's property only after receipt of payment from the second check. We have jurisdiction over this appeal pursuant to 28 U.S.C. § 158(d). We sit as a second court of review in bankruptcy matters, applying the same standards of review as the district court, and review the bankruptcy court's findings of fact for clear error. Contractors, Laborers, Teamsters and Engineers Health and Welfare Plan v. Killips (In re M & S Grading, Inc.), 526 F.3d 363, 367 (8th Cir.2008). The bankruptcy court's conclusions of law are reviewed de novo. Id. Here, the facts are not in dispute, and the interpretation of the Bankruptcy Code is reviewed de novo.
Section 547(b) of the Bankruptcy Code authorizes a bankruptcy trustee to avoid preferential transfers made to creditors in the ninety days immediately prior to a bankruptcy filing if the debtor was insolvent on the date of the transfer, the transfer was in payment of an antecedent debt, and the recipient creditor received more than the pro rata share it would have received in a Chapter 7 liquidation. Peltz v. Edward C. Vancil, Inc. (In re Bridge Info. Sys., Inc.), 474 F.3d 1063, 1066 (8th Cir.2007). Section 547 serves two purposes. First, by permitting the trustee to avoid transfers made in the ninety days before bankruptcy, creditors are discouraged from a race to the courthouse during the slide into bankruptcy. Danning v. Bozek (In re Bullion Reserve of N. Am.), 836 F.2d 1214, 1217 (9th Cir.1988), cert. denied, 486 U.S. 1056, 108 S.Ct. 2824, 100 L.Ed.2d 925 (1988). Second, it furthers the prime policy of the Bankruptcy Act of an equal distribution of the debtor's assets among similarly situated creditors. Id. The trustee may avoid the transfer of a debtor's property to a creditor that diminishes the bankruptcy estate or creates inequality among creditors, if the debtor was insolvent and the transfer was made within ninety days of the filing of the bankruptcy petition. Stevenson v. Leisure Guide of Am., Inc. (In re Shelton Harrison Chevrolet, Inc.), 202 F.3d 834, 837 (6th Cir.2000).
It is undisputed that the replacement check in this case is a preferential transfer. Miller, the debtor, was insolvent, the replacement check paid a preexisting obligation, and Kirsch received one hundred percent of what he was owed, which was paid to his bank rather than the pro rata share he would have received as an unsecured creditor.
Congress, however, has created an exception to this avoidance power if the transfer is intended by the debtor and the creditor for whose benefit such a transfer was made to be a contemporaneous exchange for new value given to the debtor, and is in fact a substantially contemporaneous exchange. Official Plan Comm. v. Expeditors Int'l of Washington, Inc. (In re Gateway Pac. Corp.), 153 F.3d 915, 917 (8th Cir.1998). The purpose of this exception is to protect transactions that do not result in a diminution of the bankruptcy estate. Anderson-Smith & Assocs., Inc. v. Xyplex, Inc. (In re Anderson-Smith & Assocs., Inc.), 188 B.R. 679, 688 (Bankr. N.D.Ala.1995). If new value is given, a contemporaneous exchange does not diminish the estate. Endo Steel, Inc. v. *473 Jonas (In re JWJ Contracting Co. Inc.), 371 F.3d 1079, 1081 (9th Cir.2004). Thus, in a cash transaction with the debtor, goods may be purchased or sold, reducing the estate, but if cash is paid over for the value of the goods, the estate is restored to the same position it had before the transaction occurred. A contemporaneous exchange for new value occurs when a debtor incurs debt and pays it by check at the same time, if the payor bank honors the check. Morrison v. Champion Credit Corp. (In re Barefoot), 952 F.2d 795, 798 (4th Cir.1991). In this case, if the debtor's check in payment of the soybeans had cleared the bank when presented, it would have been a cash transaction and the Trustee could not have set it aside. However, the debtor's check was dishonored.
In the usual case, the substitution of a bank check for a previously dishonored check from the debtor would not satisfy the new value requirement. Stewart v. Barry County Livestock Auction, Inc. (In re Stewart), 282 B.R. 871, 874 (8th Cir. BAP 2002). That is because a dishonored check creates a debtor-creditor relationship between the party issuing the check and the party who was not paid. The debtor's dishonored check is the functional equivalent of a promissory note. In re Barefoot, 952 F.2d at 800. Thus the holder of the dishonored check receives money in payment of an unsecured antecedent debt when a replacement check is received. Id. The goal of the Bankruptcy Code is to treat unsecured creditors equally, and substitution of a new bank check diminishes the estate on the basis of a previous obligation.
Here, however, Kirsch's bank did not release its security interest when Kirsch received the first (subsequently dishonored) check payable to it and Kirsch. Rather, the bank only released its security interest when it was actually paid on the second check, which was jointly payable to Kirsch and the bank. This fact distinguishes the cases relied upon by the Trustee. In In re Stewart, the trustee brought an avoidance action to recover the proceeds of two cashier's checks issued to cover dishonored personal checks delivered by the debtor on the day he purchased cattle at a livestock auction. 282 B.R. at 873. The auction company argued that the replacement checks were delivered because the company would not allow the debtor to participate until the dishonored checks were paid. Id. The court concluded the intent of the debtor and creditor was to satisfy a preexisting obligation, and the right to participate in subsequent auctions after repayment did not constitute new value. Id.
In In re Barefoot, a mobile home dealer had five mobile homes on a floor plan financing agreement with the creditor. 952 F.2d at 795. The creditor had taken all necessary steps to perfect its security interest in the mobile homes. Id. at 797. Upon receipt of a check by the creditor, it released its security interest in the mobile homes. Id. Thereafter the check was dishonored within ninety days prior to its bankruptcy filing. Id. The court concluded that the wire transfer payments in replacement of the dishonored checks was a preferential transfer and ordered the return of the payments to the bankruptcy estate. Id. at 802.
The same result was reached in Endo Steel, Inc. v. Janas (In re JWJ Contracting Co., Inc.), 371 F.3d 1079 (9th Cir.2004). There the trustee sought to avoid new payments made to subcontractors to replace insufficient funds checks. Id. at 1080. The subcontractors gave unconditional releases of their liens in exchange for checks which were subsequently dishonored by the bank. Id. at 1081. The court reasoned that the release of the liens *474 at the time of the receipt of the insufficient funds checks turned the transaction into a credit transaction and the subcontractors became unsecured creditors. Id. at 1082.
In this case, however, Kirsch's bank did not release its security interest until it received the proceeds of the second check. Because the debtor held soybeans it could not sell until the security interest was released, the debtor received new value for the replacement check. Kirsch's bank held a security interest in the soybeans that had not been released. The debtor could not sell the beans for the benefit of the unsecured creditors until he received a release of the security interest from Kirsch's bank. The bank would not release the security interest until it was paid. Under these circumstances the estate received new value, soybeans now free and clear of the security interest, in return for the bank check issued to Kirsch and the bank.

III.
For these reasons, the judgment of the district court is affirmed.
NOTES
[1]  The Honorable Ralph R. Erickson, United States District Judge for the District of North Dakota, sitting by designation.
[2]  The Honorable Richard H. Kyle, United States District Judge for the District of Minnesota.
