570.040. 1. Every person who has previously pled guilty to or been found guilty of two stealing-related offenses committed on two separate occasions where such offenses occurred within ten years of the date of occurrence of the present offense and who subsequently pleads guilty or is found guilty of a stealing-related offense is guilty of a class D felony, unless the subsequent plea or guilty verdict is pursuant to paragraph (a) of subdivision (3) of subsection 3 of section 570.030, in which case the person shall be guilty of a class B felony, and shall be punished accordingly.
2. As used in this section, the term "stealing-related offense" shall include federal and state violations of criminal statutes against stealing, robbery, or buying or receiving stolen property and shall also include municipal ordinances against same if the defendant was either represented by counsel or knowingly waived counsel in writing and the judge accepting the plea or making the findings was a licensed attorney at the time of the court proceedings.
3. Evidence of prior guilty pleas or findings of guilt shall be heard by the court, out of the hearing of the jury, prior to the submission of the case to the jury, and the court shall determine the existence of the prior guilty pleas or findings of guilt.