
564 F.3d 960 (2009)
UNITED STATES of America, Appellee,
v.
Steven P. JAMES, Appellant.
No. 08-2356.
United States Court of Appeals, Eighth Circuit.
Submitted: January 15, 2009.
Filed: May 11, 2009.
*961 Steven Vincent Stenger, argued, St. Louis, MO, for appellant.
Thomas S. Rea, AUSA, argued, St. Louis, MO, for appellee.
Before LOKEN, Chief Judge, WOLLMAN and SHEPHERD, Circuit Judges.
WOLLMAN, Circuit Judge.
Steven James was convicted of possession with intent to distribute cocaine, in violation of 21 U.S.C. § 841(a)(1), and conspiracy to distribute cocaine, in violation of 21 U.S.C. § 846. The district court[1] sentenced *962 James to 262 months' imprisonment. James appeals, arguing that the district court improperly admitted certain evidence and imposed an unreasonable sentence. We affirm.

I.
On March 13, 2006, St. Louis County police officers conducted an undercover operation aimed at curbing open-air drug dealing in northern St. Louis County. Detective Brian Flanagan pulled his unmarked vehicle into a liquor store parking lot, whereupon James approached him and asked what he was looking for. Flanagan told James he wanted a "fifty," to which James replied that "my boy down the street's got the fire." James entered the front seat of Flanagan's vehicle and directed him to a nearby residence.
Detective Flanagan handed James fifty dollars of pre-recorded buy money. James exited the vehicle and walked to the front of the residence, where he engaged in a quick exchange with a man later identified as Marcel Hogans. James returned to the car and handed Flanagan .29 grams of crack cocaine. Flanagan signaled the arrest team, and shortly thereafter James was taken from the vehicle and placed under arrest.
Several other officers pursued Hogans, who had retreated into the residence. The officers identified themselves as police and asked to enter the house. Hogans, who could see the officers outside, brandished a firearm and yelled, "I got something for your ass!" He then fled through a back door, was quickly apprehended, and was found to be in possession of the buy money.
The district court denied James's pretrial motions to exclude "any and all evidence of the acts committed by Marcel Hogans during his arrest," as well as evidence of James's 1991 conviction for delivery of cocaine. Detective Flanagan testified for the government, providing a firsthand account of the drug transaction. Two other officers testified regarding their surveillance during the transaction and their assistance with the arrests of James and Hogans.
James provided a very different account. He denied meeting Detective Flanagan at the liquor store and selling him cocaine. James testified that he was staying at the house where Hogans was apprehended and that he had walked outside in response to a commotion. He stated that he panhandled the undercover officers and that they gave him twenty dollars of marked buy money. James testified that when the officers discovered he was on parole, they arrested him and took back the money.
At the sentencing hearing, the district court determined that the appropriate guideline range was between 262 and 327 months. This range was the result of a twenty-level enhancement based on James's career offender status and a two-level obstruction of justice enhancement based on the district court's finding that James had committed perjury. James requested a departure or variance, arguing that the guideline range was unreasonable in light of the offense. After considering the § 3553(a) factors, the district court denied the request and imposed the 262-month sentence described above.

II.
James first challenges his conviction, arguing that the district court erred in admitting evidence of his prior conviction for delivery of cocaine and Hogans's out-of-court statement regarding his intention to *963 use the firearm he had brandished, as well as his conduct in fleeing the house. He also contends that the evidence was insufficient to support his conviction.
We review the district court's evidentiary rulings for abuse of discretion. United States v. Benitez, 531 F.3d 711, 716 (8th Cir.2008). James contends that evidence of his prior drug conviction was unfairly prejudicial and should have been excluded under Rule 404(b) of the Federal Rules of Evidence. As we have explained, however, Rule 404(b) is a rule of inclusion; we will reverse a district court's admission of prior conduct evidence only when the evidence had no bearing on the issues in a case and was used solely to establish a defendant's propensity to commit a crime. Benitez, 531 F.3d at 716. Evidence of prior bad acts may be used to establish a defendant's knowledge or intent, among other things. See id. Both knowledge and intent were relevant issues here in light of James's testimony that he was loitering at the scene of a drug transaction and that he received twenty dollars of marked currency by panhandling undercover police officers. This type of "mere presence" defense places a defendant's state of mind in question. United States v. Foster, 344 F.3d 799, 801 (8th Cir.2003). Moreover, the prior conduct was nearly identical to the offenses with which James was charged in the present case, and James stipulated the existence of the conviction. Although the prior conduct occurred in 1991, James spent many of the intervening years in custody  a fact that undercuts any objection to the evidence on the basis of temporal remoteness. See United States v. Williams, 308 F.3d 833, 837 (8th Cir.2002) (considering the defendant's incarceration in determining that prior conduct was not too remote to be admissible). Accordingly, the district court did not abuse its discretion in admitting evidence of James's prior conviction.
James argues that Hogans's statement regarding the firearm was inadmissible hearsay. We disagree. The statement was not admitted for the truth of the matter asserted, but, together with the circumstances in which it was made, as res gestae evidence to explain to the jury the events that gave rise to the drug transaction and James's arrest. See, e.g., United States v. DeMarce, 2009 WL 1150327 at *4 (8th Cir.2009); United States v. LaDue, 561 F.3d 855, 857-58 (8th Cir.2009); United States v. Running Horse, 175 F.3d 635, 638 (8th Cir.1999); United States v. Savage, 863 F.2d 595, 598 (8th Cir.1988).
Given the overwhelming evidence of James's guilt, which included Detective Flanagan's first-person account of the drug deal and the discovery of marked buy money on Hogans, we conclude that James's challenge to the sufficiency of the evidence borders on the frivolous. See United States v. Molsbarger, 551 F.3d 809, 812 (8th Cir.2009) (standard of review).

III.
James contends that the district court should not have applied the two-level obstruction of justice enhancement because there was insufficient evidence that he committed perjury. "A witness commits perjury when he testifies falsely under oath about a material matter with a willful intent to deceive the fact finder." United States v. Abdul-Aziz, 486 F.3d 471, 478 (8th Cir.2007) (quoting United States v. Molina, 172 F.3d 1048, 1058 (8th Cir. 1999)). Whether a defendant committed perjury is a factual finding within the purview of the district court, and we review for plain error. United States v. Garcia-Gonon, 433 F.3d 587, 592 (8th Cir.2006). Directly contradicting the eyewitness accounts *964 of three law enforcement officers, James testified that he did not enter Detective Flanagan's vehicle at the liquor store, purchase cocaine from Hogans, or exchange the drugs for fifty dollars. His testimony also included the wholly unsupported, facially incredible claim that he received twenty dollars of marked buy money by panhandling undercover police officers. Given these circumstances, the district court's determination that James committed perjury was not clearly erroneous.
Finally, James argues that his 262-month sentence was both unreasonable under 18 U.S.C. § 3553(a) and a violation of the Eighth Amendment. We review the reasonableness of a sentence in light of the factors in § 3553(a) and will reverse only if the district court abused its discretion. United States v. Miner, 544 F.3d 930, 932 (8th Cir.2008). "On appeal, we may presume a sentence within the properly calculated guidelines range is reasonable." Id. James does not take issue with the calculation of the guideline range in his case. Rather, he argues that the district court should have departed from the otherwise applicable range because the offense conduct  a basic street deal involving a small amount of cocaine  was relatively minor. The severity of the sentence, however, was largely the result of James's extensive criminal history. The district court also expressed concern that the crime was committed while James was on parole. After considering all of the § 3553(a) factors, the district court declined to depart from the guidelines, imposing instead a sentence at the bottom of the applicable range. We cannot say that the court abused its discretion in so doing.
Nor did James's sentence violate the Eighth Amendment. "An Eighth Amendment violation may be found only in the rare case in which a threshold comparison of the crime committed and the sentence imposed leads to an inference of gross disproportionality." United States v. Whitehead, 487 F.3d 1068, 1070 (8th Cir.2007) (quotation omitted). We have recognized both cocaine distribution and recidivism as factors justifying the imposition of lengthy sentences. See, e.g., id.; United States v. Collins, 340 F.3d 672, 680 (8th Cir.2003); United States v. Prior, 107 F.3d 654, 660 (8th Cir.1997). In light of James's extensive criminal history, which includes prior convictions for assault, burglary, and delivery of cocaine, we do not consider his 262-month sentence grossly disproportionate to the crime.
The judgment is affirmed.[2]
NOTES
[1]  The Honorable Jean C. Hamilton, United States District Judge for the Eastern District of Missouri.
[2]  We have reviewed the additional arguments raised in James's pro se supplemental brief, and we conclude that they are without merit.
