
    STATE of Iowa, Appellee v. Richard Leroy PARKER, Appellant.
    No. 05-0588.
    Supreme Court of Iowa.
    Feb. 8, 2008.
    Rehearing Denied April 2, 2008.
    
      Mark C. Smith, State Appellate Defender, and Nan Jennisch, Assistant State Appellate Defender, and Richard Leroy Parker, Anamosa, pro se, for appellant.
    Thomas J. Miller, Attorney General, Bruce Kempkes, Assistant Attorney General, and Christine O. Corken, Assistant Dubuque County Attorney, for appellee.
   CADY, Justice.

In this appeal from a conviction for second-degree robbery as an habitual offender, we review a variety of claims of error at trial and at sentencing. We conclude error occurred at trial, but it did not affect the outcome of the trial and did not otherwise result in the type of prejudice to justify a reversal of the conviction. We vacate the decision of the court of appeals and affirm the district court judgment and sentence.

I. Background Facts and Proceedings.

Richard Parker was convicted by a jury of second-degree robbery and sentenced as an habitual offender. The crime involved a bank robbery that took place at American Trust and Savings Bank in Dubuque shortly after 3 p.m. on July 14, 2004. The evidence at trial was sufficient to establish that Parker entered the bank, handed a bank teller a note, and demanded money. The teller described Parker as a black man wearing a hat, wig, and latex gloves, with a distinctive mark on his cheek. She gave Parker money from the counter drawer, which he placed in a black bag with green lettering on it.

The branch manager of the bank witnessed the robbery from her office. She observed the robber leave the bank, enter a blue Chevrolet Celebrity four-door sedan, and drive away. She recorded the make, model, and license plate number of the vehicle.

A customer located at the drive-through area of the bank recognized the situation as a robbery and attempted to follow the blue getaway vehicle. His pursuit, however, was short-lived. Just as the customer pulled out of the drive-through area of the bank, a red Chevrolet Blazer pulled out in front of him and impeded his travel. The driver of the red Blazer then removed the keys of the vehicle from the ignition and exited her vehicle. Consequently, the customer’s pursuit ended almost as quickly as it began.

A short time later, law enforcement officers stopped a red Blazer driven by Inger Hall-Smith. A package of latex gloves similar to the gloves worn by the robber was found in the vehicle. During the stop, Hall-Smith was questioned by an officer about her role in obstructing the pursuit by the customer. Hall-Smith responded by describing the event as a “bank robbery,” even though the officer had not referred to the incident as a bank robbery.

Sometime prior to 4 p.m., a Dubuque homeowner was mowing her lawn when Parker drove by in a vehicle matching the description of the getaway car. He stopped to ask for directions out of the subdivision in which the homeowner resided. There was only one road in and out of the subdivision, and the homeowner gave Parker the directions. The homeowner noticed a dark mark on Parker’s face.

Shortly before 4 p.m., a man who lived on a farm outside of Dubuque noticed Parker near a disabled blue car on the side of the road near his farm. The car had steam coming from the engine. Parker approached the farmer and asked for a ride. The farmer declined to help. However, another man driving a truck soon came upon the scene and gave Parker a ride into Dubuque. The driver of the truck noticed the man had makeup on his face and carried a black bag with green lettering.

Later that afternoon, police located the blue Celebrity getaway vehicle near the farm outside of Dubuque. They also found a marked $100 bill from American Trust and Savings Bank inside the vehicle.

On the evening of August 26, approximately six weeks following the robbery, Parker appeared unannounced at the Waterloo residence of James Hall, Jr., an attorney and brother of Hall-Smith, the driver of the red Blazer who prevented the witness from pursuing Parker as he drove away from the bank. Hall was acquainted with Parker and was aware his sister had been arrested for her participation in the robbery. Hall had represented Parker in the past regarding some speeding violations.

During the course of the evening of socialization and conversation, Parker detailed his participation in the bank robbery to Hall and apologized for involving Hall’s sister. He also told Hall he had committed other bank robberies in the past and had plans to rob a bank in Chicago. Parker also made other incriminating statements.

Parker spent the night at Hall’s house. The next day, Hall left his house and informed police that Parker could be found at his residence. He told police that Parker was not his client. Parker was subsequently arrested by police at Hall’s residence.

Prior to trial, Parker filed a motion with the district court to exclude from evidence at trial the incriminating statements made to Hall. Parker claimed he formed an attorney-client relationship with Hall and all the statements made to Hall were privileged communications. The district court held a hearing on the motion. Parker testified to the discussions with Hall and further testified that Hall said he would look into the status of the robbery investigation. Hall testified the two men talked and socialized well into the evening, drank alcoholic beverages, and even used illegal drugs. Hall said Parker never asked him to be his lawyer after he arrived at the house and he never had any conversation with Parker that could have led Parker to believe that Hall was representing him. He further testified he told Parker he was not getting involved in the matter and that Parker knew he was not his attorney. The district court determined no attorney-client relationship existed and denied the motion to exclude Hall as a witness.

At trial, the various witnesses to the facts and circumstances surrounding the robbery testified. The bank teller, the homeowner who was mowing the lawn, and the Good Samaritan truck driver all positively identified Parker. Hall also testified to the incriminating statements made by Parker.

Parker testified in his defense and advanced an alibi defense. He claimed he was in Chicago visiting his family on the day of the bank robbery. Parker also testified during direct examination, without elaboration, that he had never been charged with the crimes of theft, robbery, or burglary. No family members testified in support of his alibi.

On cross-examination, the State elicited from Parker that he had actually been charged with first-degree burglary in 1993. After Parker explained the offense involved an incident in which he broke the window of a vehicle, the prosecutor asked if he had any other convictions on his record. Following a prompt objection by Parker’s attorney, the following exchange occurred:

STATE: I believe it falls clearly within the rules, Your Honor, when there are felony convictions, not to mention the fact that he opened the door by describing that he hadn’t been charged with previous particular crimes. I don’t believe he can be allowed to mislead the jury otherwise. The rules are very clear, but the procedure is for felony convictions.
THE COURT: I agree. Go ahead.
DEFENSE COUNSEL: Your Honor, then I wish to simply remind the Court of the motions prior to the case, and I wish to remind the Court of the rules of evidence, and particularly, I believe it’s 603.
STATE: I believe its Rule 5.609(a)(1).
THE COURT: The Court is well acquainted with that, and you’ve opened the door and asked him questions pertaining to his prior history. I believe the State has the right to go into that subject, especially if it’s a felony or anything related to an untruthful matter.
DEFENSE COUNSEL: Your Honor, my client was asked specific questions.
THE COURT: And gave very specific answers. That opens the door to this inquiry. Go ahead.
DEFENDANT: Okay. Repeat your question.
Q: Could you read the question back please? (Whereupon, the requested portion of the proceeding was read back by the court reporter.) A: Yes.
Q: You have convictions for possession of a schedule I substance? A: Yes. Thirteen years ago, I was charged with, you know, you know, I believe it was aiding and abetting or delivery of a controlled substance, yes.
Q: Delivery of a schedule II controlled substance within a thousand feet of a school and delivery of a schedule II controlled substance; do you recall that, sir? A: I just said I did, yes.
Q: And you were convicted of it? A: Yes, I was.
Q: And you went to prison? A: Yes, I did.

The jury convicted Parker of second-degree robbery. The district court sentenced Parker as an habitual offender after he was found to be an habitual offender at the enhancement phase of the trial.

Parker appealed, and asserted five claims of error: (1) the conversations with Hall should have been excluded as privileged attorney-client communications, (2) the evidence of his prior drug convictions should not have been admitted, (3) his attorney rendered ineffective assistance of counsel, (4) his sentencing as an habitual offender was illegal, and (5) prosecutorial misconduct. We transferred the case to the court of appeals. The court of appeals held the district court abused its discretion by admitting evidence of defendant’s prior drug convictions and remanded for a new trial. The court of appeals did not address Parker’s other claims of error. The State sought, and we granted, further review.

II. Standards of Review.

We review each issue presented according to its appropriate standard. Regarding the admission of the prior crimes evidence,

[t]his court “generally review[s] eviden-tiary rulings for abuse of discretion.” Williams v. Hedican, 561 N.W.2d 817, 822 (Iowa 1997); accord State v. Bugely, 562 N.W.2d 173, 177 (Iowa 1997) (applying abuse of discretion standard in reviewing admission of other crimes evidence). An abuse of discretion occurs when the trial court exercises its discretion “on grounds or for reasons clearly untenable or to an extent clearly unreasonable.” State v. Maghee, 573 N.W.2d 1, 5 (Iowa 1997). “A ground or reason is untenable when it is not supported by substantial evidence or when it is based on an erroneous application of the law.” Graber v. City of Ankeny, 616 N.W.2d 633, 638 (Iowa 2000).

State v. Rodriquez, 636 N.W.2d 234, 239 (Iowa 2001).

Whether an attorney-client relationship existed is a preliminary question to be determined by the trial court. Iowa R. Evid. 5.104. When the preliminary question is one of fact, “we give deference to the district court’s factual findings and uphold such findings if they are supported by substantial evidence.” State v. Long, 628 N.W.2d 440, 446-47 (Iowa 2001).

“Where a defendant alleges ineffective assistance of counsel, our standard of review is de novo.” State v. Tejeda, 677 N.W.2d 744, 754 (Iowa 2004). We generally reserve ineffective-assistance-of-counsel claims for postconviction relief. Id.

We may correct an illegal sentence at any time, State v. Woody, 613 N.W.2d 215, 217 (Iowa 2000), but our review of the district court’s sentence is limited to errors at law. Iowa R.App. P. 6.4; State v. Morris, 416 N.W.2d 688, 689 (Iowa 1987).

III. Discussion.

A. Attorney-Client Privilege. Parker claims the statements he made to Hall were privileged attorney-client communications and should not have been admitted into evidence by the district court at trial. An attorney-client privilege arises only if an attorney-client relationship has been created. Thus, the first task is to determine if an attorney-client relationship existed at the time the statements were made.

We have adopted a three-part test to determine the existence of an attorney-client relationship. The relationship exists when: “(1) a person sought advice or assistance from an attorney, (2) the advice or assistance sought pertained to matters within the attorney’s professional competence, and (3) the attorney expressly or impliedly agreed to give or actually gave the desired advice or assistance.” Comm. on Prof'l Ethics & Conduct v. Wunschel, 461 N.W.2d 840, 845 (Iowa 1990).

This standard is compatible with the Restatement (Third) of the Law Governing Lawyers, which provides, in relevant part, that a relationship of lawyer and client arises when:

(1) A person manifests to a lawyer the person’s intent that the lawyer provide legal services for the person; and either
(a) the lawyer manifests to the person content to do so: or
(b) the lawyer fails to manifest lack of consent to do so, and the lawyer knows or reasonably should know that the person reasonably relies on the lawyer to provide the services....

Restatement (Third) of the Law Governing Lawyers § 14 (2002). Thus, the relationship rests on contract, but may be implied from the conduct of the parties. Healy v. Gray, 184 Iowa 111, 115,168 N.W. 222, 224 (1918). The burden of proof is on the party seeking to establish the privilege. Bailey v. Chicago, Burlington & Quincy R.R., 179 N.W.2d 560, 564 (Iowa 1970). Comments to the Restatement reveal the “client’s intent may be manifest from surrounding facts and circumstances,” but recognize “a lawyer may answer a general question about the law, for instance in a purely social setting, without a client-lawyer relationship arising.” Restatement § 14 cmt. c. Likewise, “a lawyer may manifest consent to creating a client-lawyer relationship in many ways,” including when a lawyer reasonably should know a person reasonably relies on the lawyer to provide services and “does not inform the person that the lawyer will not do so.” Id. § 14 cmt. e.

In this case, the district court determined no attorney-client relationship existed between Hall and Parker. We give deference to the preliminary findings by the district court used to reach this ruling. The district court found Parker did not go to Hall’s residence to obtain his legal services, but contacted Hall to apologize for involving Hall’s sister in the robbery. In doing so, Parker talked about his participation in the robbery, as well as other crimes he had committed. In response to a discussion about the status of the criminal investigation into the robbery, Hall indicated he would look into the matter generally and report back. Parker also asked Hall at one point about the statute of limitations for robbery. The conversations were rambling at times and continued long into the evening. The evening included the consumption of alcoholic beverages and the use of illegal drugs. There was no discussion at any time between the two men about Hall representing Parker, and no strategy or advice about any course of action Parker should pursue was discussed. Parker never expressed a desire to turn himself over to police, but instead told Hall he was on his way to Chicago to rob a bank in order to provide financial assistance to Hall’s sister.

The district court also found Hall contacted the police the following day because he did not feel an attorney-client relationship existed. The evidence also showed that Parker waived his Miranda rights and agreed to talk to police after his arrest. Parker did ask the police if Hall could be present during the interview, but was told potential witnesses were not permitted to be present. Parker never told police Hall was his attorney and never indicated at any other time during the arrest process that Hall was his attorney.

We first examine the evidence of an intent by Parker for Hall to provide legal services to him. Parker never asked Hall to represent him, and the two men never verbally explored the possibility of representation. See Restatement § 14 cmt. c. Thus, Parker’s intent to create an attorney-client relationship can only arise by implication from the conversations that occurred during the evening and the surrounding circumstances.

While some of the conversations could have been consistent with Parker’s claim that he intended for Hall to represent him, it is clear the conversations took place in the context of a larger conversation unrelated to legal services during an evening of socialization between the men. A discussion of legal matters in a social setting does not necessarily give rise to an attorney-client relationship. Id. Moreover, a person seeking to establish an attorney-client relationship must manifest the intent to the attorney. In this case, Hall never felt Parker was asking him to be his attorney at any point during the course of the evening.

The same conversations relied upon by Parker to establish his intent for Hall to represent him were also used by Parker to show Hall’s intent to represent him. In particular, Parker claims the promise by Hall to check out the status of the robbery investigation made it reasonable for him to believe Hall would be representing him regarding his concerns over his participation in the robbery.

An attorney-client relationship can arise when the person seeking to establish the relationship “reasonably relies upon the attorney to provide legal services, even when the attorney has not communicated a willingness to represent” the person. Restatement § 14 cmt. e. However, “in appraising whether a person’s reliance was reasonable, courts consider that lawyers ordinarily have superior knowledge of what representation entails and that lawyers often encourage clients ... to rely upon them.” Id. In this case, Hall did not encourage Parker to rely upon him.

As confirmed by Hall’s actions in going to the police the day following the conversations, Hall never believed the circumstances established an attorney-client relationship. Additionally, Parker could not have reasonably relied upon Hall to provide legal services based merely on Hall’s willingness to check into the status of the criminal investigation and the limited questions he propounded pertaining to the robbery. Without any discussion about the specific need for representation or the nature of legal services to be provided, Parker could not have reasonably relied upon Hall to protect his legal interests through an attorney-client relationship. We conclude the findings of the trial court support the conclusion that no attorney-client relationship arose between Hall and Parker. Thus, the trial court did not err in admitting the incriminating statements made to Hall by Parker.

B. Prior Convictions.

1. Propriety of the State’s cross-examination. The district court permitted the State to introduce evidence of Parker’s prior convictions under the theory that defense counsel “opened the door” by asking Parker on direct examination whether he previously had been charged with theft, robbery, or burglary. On appeal, Parker concedes the State was appropriately permitted to ask him about the prior burglary charge on cross-examination, but he argues that evidence of his prior drug convictions should have been excluded as prejudicial under Iowa Rule of Evidence 5.609.

We begin the resolution of this issue by recognizing that defendants in criminal cases who take the stand and testify in their defense place their credibility in issue and are typically subject to cross-examination the same as any other witness. State v. Bauer, 324 N.W.2d 320, 323 (Iowa 1982). Thus, the credibility of a criminal defendant who testifies at trial can generally be attacked by evidence of a conviction of a crime when the crime is punishable by more than one year imprisonment or involves dishonesty or a false statement. Iowa R. Evid. 5.609(a). The rationale behind this general impeachment rule is that evidence of the moral qualities of a witness can cast light on the probability of the truthfulness of the testimony. State v. Hackney, 397 N.W.2d 723, 726 (Iowa 1986).

The general rule of impeachment by pri- or convictions is limited, however, due in part to a “danger that the jury will view evidence of a past conviction as evidence of present guilt, or as reason to convict with little concern for present guilt.” Id. To guard against this danger, trial courts are required to employ a strenuous balancing test and admit evidence of a crime only if “the probative value of admitting this evidence outweighs its prejudicial effect to the accused.” Iowa R. Evid. 5.609(a)(1).

The State seeks to avoid the scrutiny of this balancing test by arguing that the impeachment rule was never implicated in this case because the evidence of prior crimes was not elicited on cross-examination by the State for the purpose of attacking Parker’s credibility as a witness. Instead, the State claims Parker projected the false impression to the jury on direct examination that he had no prior record and was an honest, law-abiding person; and consequently “opened the door” for the State to correct the false impression by presenting evidence of his true criminal background on cross-examination. Thus, the State argues rule 5.609 does not apply because Parker “opened the door” for the admission of his prior criminal record.

Our prior cases recognize an “opening the door” principle of evidence. This rule pertains to the ability of a party to rebut inadmissible evidence offered by an adversary and provides that “ ‘one who induces a trial court to let down the bars to a field of inquiry that is not competent or relevant to the issues cannot complain if his adversary is also allowed to avail himself of the opening.’ ” State v. Mitchell, 670 N.W.2d 416, 420 (Iowa 2003) (quoting 1 John W. Strong, et al., McCormick on Evidence § 57, at 253 (5th ed. 1999) [hereinafter McCormick on Evidence]). The rule is also known as “fighting fire with fíre.” 1 McCormick on Evidence § 57, 252. Yet, it is not applicable until one party injects an incompetent, irrelevant, or inadmissible matter into trial. See James A. Adams & Joseph P. Weeg, Iowa Practice: Evidence § 5.103:8, at 38 (2007).

In this case, the testimony by Parker on direct examination that he had never been charged with three types of crimes implied he was an honest, law-abiding person and had no criminal record involving dishonesty. On its face, this evidence and its implication were neither immaterial nor irrelevant. If true, it casts light on Parker’s moral qualities for truthfulness as a witness.

More importantly, there is no “open the door” principle of evidence that permits the State to engage in unrestricted cross-examination of a defendant once it believes the defendant has presented false and misleading testimony on direct examination. The State correctly observes that a defendant who testifies at trial should not be permitted to resort to perjury or false characterization on direct examination without fear of being exposed by the State on cross-examination. Like all witnesses, a defendant is subjected to procedures that exist to provide an assurance of accuracy in testimony. 1 McCormick on Evidence § 129, at 489 (addressing a criminal defendant’s privilege against self-incrimination and explaining a defendant who waives the privilege must submit to cross-examination to provide the prosecution an opportunity to test the defendant’s assertions); see also Walder v. United States, 347 U.S. 62, 74 S.Ct. 354, 98 L.Ed. 503 (1954). Yet, the State can only test the accuracy of the testimony as provided by the governing rules. The rules of evidence open the door for the State to expose false statements and claims, but only as far as specifically provided by the rules.

The credibility of a witness can be attacked in a variety of ways. These methods of impeachment may occur at trial either on cross-examination of the witness or by the presentation of extrinsic evidence. 1 McCormick on Evidence § 34, at 124.

In this case, the State sought to impeach Parker on cross-examination by asking him to acknowledge the inaccuracy of the criminal history he recounted on direct examination. It then continued in cross-examination by asking Parker to acknowledge the existence of two drug-related convictions.

Cross-examination can be a powerful elixir for the truth, and our rules permit cross-examination as a means to both delve into the story told by the witness on direct examination by testing such matters as partiality, memory, and perception, and to challenge credibility. Iowa R. Evid. 5.611 (providing cross-examination should generally “be limited to the subject matter of the direct examination and matters affecting the credibility of the witness”). The nature and scope of cross-examination is governed by the sound discretion of the trial court. State v. Martin, 385 N.W.2d 549, 552 (Iowa 1986).

Once Parker testified he had never been charged with burglary, the State was permitted to impeach Parker’s assertion by asking him about his prior charge for burglary. See United States v. Valencia, 61 F.3d 616, 619 (8th Cir.1995) (allowing cross-examination of the facts of a specific prior conviction in which the defendant previously attempted to minimize his guilt as to the prior conviction); United States v. Amahia, 825 F.2d 177, 179-80 (8th Cir.1987) (same); United States v. Babbitt, 683 F.2d 21, 25 (1st Cir.1982) (affirming admission of defendant’s remote arrest to rebut defendant’s claim that he had no prior record). However, the impeachment was accomplished once Parker admitted the prior burglary-charge on cross-examination, and the falsehood, and false impression, given by Parker to the jury on direct examination was exposed. At this point, any further impeachment by cross-examination would be limited to other prior crimes of theft, robbery, or burglary or perhaps other crimes involving dishonesty. See Amahia, 825 F.2d at 180 (limiting cross-examination to those “facts which are relevant to the direct examination”). Importantly, Parker did not testify that he never committed any crimes. Under the circumstances, additional cross-examination with evidence of prior drug convictions was beyond the scope of direct examination. It would have been an abuse of discretion for the trial court to admit the prior drug convictions on cross-examination because it was not within the scope of the subject matter of the direct examination. We therefore proceed to consider whether the prior drug convictions were admissible on cross-examination to impeach the credibility of Parker as a witness. See State v. McCowen, 297 N.W.2d 226, 227 (Iowa 1980) (“[W]e will uphold a ruling of the court on the admissibility of evidence on any ground appearing in the record, whether urged below or not.”).

As previously mentioned, a defendant who testifies at a criminal trial can be impeached by evidence of a conviction of a crime, subject to certain limitations. Iowa R. Evid. 5.609. In this case, the drug convictions were serious enough to qualify as impeachable crimes under rule 5.609, but were more than ten years old. For convictions more than ten years old, rule 5.609(b) provides, in pertinent part:

Evidence of a conviction under this rule is not admissible if a period of more than ten years has elapsed since the date of the conviction or of the release of the witness from the confinement imposed for that conviction, whichever is the later date, unless the court determines, in the interests of justice, that the probative value of the conviction supported by specific facts and circumstances substantially outweighs its prejudicial effect.

Rule 5.609(b) “creates a rebuttable presumption that convictions over ten years old are more prejudicial than probative and are therefore inadmissible.” State v. Roby, 495 N.W.2d 773, 775 (Iowa Ct. App.1992). Thus, convictions falling under rule 5.609(b) “should be admitted only in exceptional circumstances.” Id. Clearly, however, rule 5.609(b) is not “an absolute bar to the admission of evidence of convictions which are over ten years old.” Id. at 776.

In applying the balancing test, we first consider the circumstances of the prior crimes. We have previously stated that drug possession convictions have little bearing on veracity. Id. A conviction for delivery of a controlled substance is likewise distinguishable from crimes we have previously found to be probative of credibility, like perjury and theft offenses. Compare, e.g., State v. Zaehringer, 325 N.W.2d 754, 755-58 (Iowa 1982) (holding delivery-of-marijuana offense inadmissible under common-law impeachment rule because that crime does not involve dishonesty or false statement), with Roby, 495 N.W.2d at 775 (finding perjury offense highly probative), and State v. Latham, 366 N.W.2d 181, 184 (Iowa 1985) (holding robbery involves “ ‘stealing in an elemental sense’ and so involves dishonesty” (quoting Zaehringer, 325 N.W.2d at 756)).

The two prior drug convictions not only potentially cast Parker as a drug dealer, but one conviction involved dealing drugs near schools. An obvious danger exists that a jury may convict such an individual with little concern for his actual guilt as to the crime in question. See United States v. Ong, 541 F.2d 331, 339-40 (2d Cir.1976) (stating “there are few subjects more potentially inflammatory than narcotics”); State v. Liggins, 524 N.W.2d 181, 188-89 (Iowa 1994) (finding admission of evidence of cocaine delivery inherently prejudicial because “[i]t appeals] to the jury’s instinct to punish drug dealers”). These circumstances reveal a clear danger of prejudice. Moreover, there were no circumstances presented to reveal the two convictions had any particular probative value to aid the jury in assessing Parker’s credibility as a witness. It would have been an abuse of discretion for the trial court to determine, in the interest of justice, that the probative value of the prior convictions substantially outweighed their prejudicial effect. The prior drug convictions were inadmissible under rule 5.609(b), and it is unnecessary to further consider their admissibility under rule 5.609(a). The State does not argue the prior convictions were admissible under any other theory or rule of evidence, and we find no other grounds to support the admission of the evidence. The trial court erred in admitting the prior drug convictions into evidence at trial.

2. Harmless error. In reviewing trial court error on appeal, we follow the rule that an “[e]rror may not be predicated upon a ruling which admits or excludes evidence unless a substantial right of the party is affected.... ” Iowa R. Evid. 5.103(a). Thus, error in an evi-dentiary ruling that is harmless may not be a basis for relief on appeal. See State v. Sullivan, 679 N.W.2d 19, 29 (Iowa 2004). We presume prejudice under this approach, unless the contrary is affirmatively established. Id. When a nonconstitutional error is claimed, as in this case, the test is whether the rights of the objecting party have been “injuriously affected by the error” or whether the party has “suffered a miscarriage of justice.” Id. (quoting State v. Trudo, 253 N.W.2d 101, 107 (Iowa 1977)).

We have already concluded the district court erred by admitting the prior drug-conviction evidence, based on our determination that the probative value of the evidence did not substantially outweigh its prejudicial effect. See Iowa R. Evid. 5.609(b). However, this analysis differs from the separate analysis we make under rule 5.103(a). See Sullivan, 679 N.W.2d at 30. The prejudice test under rule 5.609 is only used to determine the admissibility of the evidence and our conclusion in this case that the district court did not properly apply the test reveals an abuse of discretion in admitting the evidence. Id. Yet, it is another question whether the erroneous evidence prejudiced the rights of the defendant to a fair trial. Thus, the rule 5.103(a) harmless-error analysis is a broader test. It accepts that error has seeped into the trial, but does not allow the error to serve as grounds for reversal of the conviction or other relief if the overall circumstances affirmatively establish the error did not affect the substantive rights of the defendant. Id.

We have previously acknowledged the prejudicial impact of impeachment by prior convictions on the trial of an accused who testifies in the case. See id. (citing cases and studies supporting the likely use of evidence of impeachment by prior convictions by jurors as substantive proof of guilt). Particularly, when the prior convictions are for crimes that are similar to the crime for which the defendant is on trial, there is an obvious danger that

despite instructions, the jury might misuse the evidence and give more heed to the past convictions as evidence that the accused is the kind of man who would commit the crime charged, or even that he ought to be imprisoned without too much concern for present guilt or innocence, than they will to the legitimate bearing of the past convictions on credibility.

1 McCormick on Evidence § 42, at 168-69.

Notwithstanding, we consider a variety of circumstances in determining the existence of harmless error, including the existence of overwhelming evidence of guilt. State v. Martin, 704 N.W.2d 665, 673 (Iowa 2005). Moreover, we have relied on the existence of overwhelming evidence in finding harmless error despite the existence of error based on prior-conviction evidence. See State v. Holland, 485 N.W.2d 652, 656 (Iowa 1992) (holding defendant could not show prejudice due to admission of evidence suggesting defendant had previously been convicted of a crime “because of the overwhelming evidence, albeit much of it circumstantial, connecting [the defendant] with the charged crimes”).

In this case, the conviction was clearly based on overwhelming evidence of Parker’s guilt. Parker was positively identified as the bank robber by the bank teller, and two witnesses positively identified him as driving the getaway car during his circuitous escape from the bank. Money from the bank was also found in the car. Although Parker attempted to disguise his appearance during the robbery, none of the witnesses had any difficulty identifying him as the bank robber and driver of the getaway car. Moreover, Parker admitted to Hall that he committed the robbery. Additionally, he failed to produce any witness to corroborate his alibi defense. The improper prior-conviction evidence admitted at trial was also dissimilar to the robbery charge for which Parker was on trial. See State v. Martin, 704 N.W.2d 674, 676 (Iowa 2005) (attributing the prejudicial nature of admission of prior convictions “first and foremost” to their similarity to the crime at issue). Under all the circumstances, we conclude the error in admitting the prior conviction was harmless.

C. Ineffective Assistance of Counsel and Prosecutorial Misconduct.

When “an ineffective assistance of counsel claim is raised on direct appeal from the criminal proceedings the court may decide the record is adequate to decide the claim or may choose to preserve the claim under chapter 822 [postconviction proceedings].” Iowa Code § 814.7(3). Yet, “[o]rdinarily, we do not decide ineffective-assistance-of-counsel claims on direct appeal.” State v. Tate, 710 N.W.2d 237, 240 (Iowa 2006). When the district court record is sufficient to evaluate the claim, however, we will resolve it on direct appeal. Id.

A claim of ineffective assistance of counsel must be supported by evidence that (1) “counsel failed to perform an essential duty, and (2) prejudice resulted.” Id. However, “[i]f sufficient prejudice is not shown, we need not address whether counsel breached an essential duty.” State v. Wissing, 528 N.W.2d 561, 564 (Iowa 1995).

Parker argues his trial counsel was ineffective in two separate instances. First, he asserts counsel was ineffective for failing to object to the admission of his prior drug convictions. Second, he argues counsel was ineffective for failing to object to references made during the State’s case in chief and closing argument and during the State’s cross-examination of him during presentation of his case, suggesting he was in possession of a stolen vehicle. This claim was the basis for a pretrial motion in limine filed by Parker to exclude evidence that he was driving a stolen vehicle when he visited Hall in Waterloo. The State agreed with the motion, and it was granted by the district court. During Hall’s direct examination by the State, however, Hall answered a question by the prosecutor by mentioning that Parker told him he drove a stolen car to his house. Defense counsel made no objection to the testimony and did not request to strike it from the record. In addition to claiming these incidents amounted to ineffective assistance of counsel, Parker asserts prosecutorial misconduct as a separate ground for error.

While we agree with Parker that evidence was improperly admitted at trial, the trial court record supports a finding that no prejudice occurred. The prejudice component of an ineffective-assistance-of-counsel claim requires a showing of a reasonable probability that the result of the trial would have been different but for counsel’s error. State v. Atwood, 602 N.W.2d 775, 784 (Iowa 1999).

Our review of the trial record convinces us that the evidence of Parker’s prior drug convictions and evidence he possessed a stolen car did not affect the outcome of the trial. As we have previously observed, the evidence of guilt was overwhelming. See State v. Casady, 597 N.W.2d 801, 806 (Iowa 1999) (concluding no prejudice from improper admission of other crimes when the case against the defendant was “very substantial”). Moreover, any prejudice visited on Parker by evidence that he possessed a stolen car when he visited Hall was diminished by Hall’s testimony that Parker admitted that he stole the car that he used to commit the bank robbery. We reject Parker’s claim of ineffective assistance of counsel on the basis that Parker cannot establish prejudice.

We also reject the separate claim of prosecutorial misconduct asserted by Parker. First, the stolen-car testimony during the State’s case in chief was nonre-sponsive to the question propounded by the prosecutor. Additionally, the references to the stolen car during cross-examination of Parker and the State’s closing argument were not pervasive, and the stolen-car evidence at issue was far removed from the central issue in the case involving the bank robbery. See State v. Graves, 668 N.W.2d 860, 869 (Iowa 2003) (listing the pervasiveness of the misconduct and its significance to the central issues in the case as important factors when considering prosecutorial misconduct). Finally, the evidence of guilt was overwhelming. See id. (citing factors to use to analyze prejudice). No prejudice occurred that entitled Parker to a new trial.

D. Sentencing as an Habitual Offender. Parker claims the district court erred by sentencing him as an habitual offender. Under our law, an habitual offender is “any person convicted of a class ‘C’ or a class ‘D’ felony, who has twice before been convicted of any felony in a court of this or any other state, or of the United States.” Iowa Code § 902.8. We have held this definition requires “each succeeding conviction must be subsequent in time to the previous convictions, both with respect to commission of the offense and to conviction.” State v. Hollins, 310 N.W.2d 216, 217 (Iowa 1981). Consequently, the habitual offender statute only applies when conviction for the first predicate offense occurs before commission of the second predicate offense and conviction of the second predicate offense occurs before commission of the primary offense.

At the habitual-offender stage of the trial, the jury found Parker was an habitual offender based on the following:

1. The defendant was convicted on or about October 4, 1993, in the Iowa District Court for Dubuque County of delivery of cocaine within 1000 feet of a public school while being an habitual offender.
2. Defendant was convicted on or about October 4, 1993, in the Iowa District Court for Dubuque County of delivery of cocaine.

Based on these findings by the jury, the district court sentenced Parker as an habitual offender.

On appeal, Parker claims the sentence imposed was illegal because the two convictions used by the jury were entered on the same day and constitute only one predicate offense. See Hollins, 310 N.W.2d at 217-18 (holding defendant was not habitual offender where he pled guilty to two putative predicate offenses on the same day). The State acknowledges the two prior convictions used to support the habitual-offender status occurred on the same date, but argues the statutory requirement of two separate prior convictions to support the habitual-offender status was satisfied by the prior conviction for delivery of cocaine because it was enhanced as “an habitual offender.” In other words, the State argues that a prior habitual-offender conviction satisfies the statutory definition of an habitual offender for enhancement of a current conviction because it necessarily means the person “has twice before been convicted” of the predicate felonies. See Iowa Code § 902.8.

This issue arises for the first time at this stage of the proceedings because a defendant is permitted to challenge an illegal sentence at any time. State v. Woody, 613 N.W.2d 215, 217 (Iowa 2000). An illegal sentence is void, which permits an appellate court to correct it on appeal without the necessity for the defendant to preserve error by making a proper objection in the district court. Id.

When faced with a claim of an illegal sentence, we must first consider whether the sentence was illegal. An illegal sentence is one not permitted by law. Id. The law does not permit a defendant to be sentenced as an habitual offender if the prior convictions relied upon are not felonies or do not occur in the required sequence. If the record in a case shows the prior convictions are not convictions that meet the required predicate conditions, the imposition of a sentence as an habitual offender is illegal.

While Parker raises a substantial argument as a response to the procedure used and actions taken by the district court in finding him to be an habitual offender, we cannot conclude as a matter of law, on this record, that the sentence was illegal. By failing to object to the use of a prior habitual-offender conviction as underlying evidence to support the habitual-offender status of the felony that is the subject of the sentencing, Parker consented to the method used by the district court to determine his habitual-offender status. The evidence before the district court revealed Parker was an habitual offender at the time he committed the burglary. Consequently, unlike other cases in which we can examine the record on appeal to discern the absence of two qualifying prior convictions, the record in this case shows Parker was an habitual offender. Therefore, we cannot declare as a matter of law that Parker’s sentence was illegal. In the event Parker did not actually have two qualifying prior felonies to support enhancement as an habitual offender, relief would be available through a postconviction-relief claim based on ineffective assistance of counsel for failing to object to the underlying trial procedure used to determine the enhancement of the sentence. On this record, we find the sentence imposed was not illegal.

IV. Conclusion.

We vacate the decision of the court of appeals and affirm the judgment and sentence of the district court.

DECISION OF COURT OF APPEALS VACATED; DISTRICT COURT AFFIRMED. 
      
      . It has been suggested that, under certain circumstances, the introduction of an attorney-client communication could violate the Fifth Amendment privilege against self-incrimination or the Sixth Amendment right to effective assistance of counsel. See Penry v. Johnson, 532 U.S. 782, 121 S.Ct. 1910, 150 L.Ed.2d 9 (2001); Smith v. State, 394 Md. 184, 905 A.2d 315, 325 (2006); B. John Burns, Iowa Practice: Criminal Procedure § 26:3, at 423 (2006). Parker’s claim on appeal is confined to a violation of the statutory attorney-client privilege.
     
      
      . When a witness other than the accused testifies, rule 5.609 allows evidence of past serious crimes subject only to rule 5.403. Iowa R. Evid. 5.609. As such, prior convictions of a witness are to be admitted unless their probative value is substantially outweighed by unfair prejudice. Id. r. 5.403. In contrast, “evidence that an accused has been convicted of such a crime shall be admitted if the court determines that the probative value of admitting this evidence outweighs its prejudicial effect.” Id. r. 5.609. Further, when the later of the conviction or the accused’s release from confinement is more than ten years past, such evidence is not admissible unless "the probative value of the conviction supported by specific facts and circumstances substantially outweighs its prejudicial effect.” Id.
      
     
      
      . Generally, there are five methods of attack upon the credibility of a witness. 1 McCormick on Evidence § 33, at 123-24. First is by evidence that the witness has made statements inconsistent with the present testimony on a prior occasion. Id. § 33, at 124. Second is by evidence that the witness is not impartial. The third method is by an attack on the witness' character. Id. The fourth method involves an attack on the inability of the witness to properly observe or recount matters that were the subject of direct examination. Id. The last method is by proof through other witnesses that the material facts were not as testified to by the witness. Id.
      
     
      
      . This type of impeachment requires a good faith basis for the inquiry and is limited to intrinsic evidence when the matter inquired into is collateral to the historical merits of the case; i.e. the cross-examiner cannot challenge the witness’ answer with extrinsic evidence but is "stuck” with it. 1 McCormick on Evidence § 33, at 124.
     
      
      . Parker makes no claim of constitutional error. See 1 McCormick on Evidence § 42, at 155 ("The suggestion has also been made that impeachment of the accused by showing prior convictions is unconstitutional, but to date, no federal or state court has embraced the suggestion.’’). The test for constitutional error is slightly different. See State v. Simmons, 714 N.W.2d 264, 275 (Iowa 2006).
     