
14 Kan. App. 2d 449 (1990)
793 P.2d 763
STATE OF KANSAS, Appellee,
v.
WILLIAM McLAREN, Appellant.
No. 63,646
Court of Appeals of Kansas.
Opinion filed June 1, 1990.
Charles D. Dedmon, assistant appellate defender, and Steven R. Zinn, deputy appellate defender, for the appellant.
Gene Porter, county attorney, and Robert T. Stephan, attorney general, for the appellee.
Before ABBOTT, C.J., BRAZIL, J., and PAUL E. MILLER, District Judge, assigned.
MILLER, J.:
William McLaren appeals from the refusal of the trial court to allow withdrawal of his guilty plea to one count of felony theft, K.S.A. 21-3701 (Ensley 1981), in case No. 84 CR 501. He also appeals his jury conviction for two counts of sale of marijuana, K.S.A. 1987 Supp. 65-4127b, and the sentence imposed therefor in case No. 87 CR 128. The cases are consolidated on appeal.
McLaren raises four issues:
1. Whether the trial court erred in failing to permit appellant to withdraw his guilty plea;
2. whether the trial court erred in failing to give the jury appellant's requested instruction on the defense of entrapment;
*450 3. whether the trial court erred in permitting evidence tending to prove appellant's involvement with drugs on other occasions; and
4. whether during closing argument the prosecutor impermissibly commented upon appellant's post-arrest silence.
Because we answer the first two issues in the affirmative, we need not reach the latter two.
On August 12, 1985, appellant appeared before the trial court and, pursuant to plea negotiations, entered a plea of guilty to one count of felony theft. The record on the plea shows the following:
"THE COURT: Will the State recite the plea negotiations for the record?
"MISS WILKINSON: Defendant will be pleading to the crime as charged, we will be recommending probation and payment of restitution and I am leaving it up to the discretion of the Court what of the transportation expense to assess.
"THE COURT: You understand that you are charged with a Class D felony?
"MISS WILKINSON: We would be willing to amend that charge to a Class E felony. Technically, at the time the crime was committed that was a  theft was a D but now it's an E.
"THE COURT: You understand, Mr. McLaren, you are now charged with a Class E felony and if convicted of a Class E felony you could be sentenced to serve a minimum term of one year and a maximum term of three to five years and you may be ordered to pay a fine in lieu of such sentence or in addition to the sentence in an amount not to exceed $10,000?"
After accepting the plea, the court imposed a sentence of one to two years and placed the appellant on probation. At the time of the commission of the offense, felony theft was a class D felony. K.S.A. 21-3701 (Ensley 1981). Between January of 1984 when the theft was committed and the time of appellant's plea, the statute was amended to make felony theft a class E felony. L. 1984, ch. 119, § 2. The effective date of the amendment was May 17, 1984, and the amendment specifically applied prospectively only. The State did attempt to amend the classification of the charge to an E felony and, as pointed out by the sentencing journal entry, the court apparently accepted that amendment and sentenced defendant accordingly.
Because the trial court was without authority to reduce the classification of felony theft, the sentence imposed was illegal. "It has long been the rule in this state that the crime and penalty *451 in existence at the time of the offense are controlling unless the legislature has given retroactive effect to any statutory changes made subsequent to the time of the commission of the crime." State v. Van Cleave, 239 Kan. 117, 122, 716 P.2d 580 (1986).
Prior to the expiration of his probationary period, the State filed a motion to revoke appellant's probation, based in part upon the activity which led to his convictions in case No. 87 CR 128. On May 27, 1988, the trial court heard the State's motion, revoked appellant's probation, and ordered his incarceration under the original one-to two-year term. After notification by the Department of Corrections that the original sentence was improper, the trial court, on September 9, 1988, by order nunc pro tunc, modified appellant's sentence to one to five years. Appellant objected to the nunc pro tunc order and the matter was set for hearing on January 13, 1989, at which time appellant sought to withdraw his guilty plea, claiming that the plea bargain was based upon an agreement that the court impose an illegal sentence. The motion to withdraw the plea was denied, and appellant brought this appeal.
All of this is significant because during the period appellant was on probation he was charged with and convicted of two counts of selling marijuana in case No. 87 CR 128. On May 27, 1988, the same day appellant's probation was revoked, appellant was sentenced to three to ten years on Count I of 87 CR 128 and seven to twenty years on Count II, the sentence having been enhanced pursuant to the Habitual Criminal Act based upon the conviction in case No. 84 CR 501.
Appellant now contends that, if he is allowed to withdraw his plea in 84 CR 501, the enhanced sentence in Count II of 87 CR 128 must also fail, as there would be no underlying felony conviction to serve as its basis.
The issue before this court, whether appellant should be allowed to withdraw his plea of guilty because the plea negotiation which induced the plea was apparently based upon a promise to recommend an illegal sentence, is one of first impression in Kansas. Our courts have spoken to various other issues relating to plea bargains, all of which issues have as their genesis Santobello v. New York, 404 U.S. 257, 30 L.Ed.2d 427, 92 S.Ct. 495 (1971). That case stands for the proposition that the prosecution *452 may not renege on promises made in the course of plea negotiations. Appellant, in his brief, places much reliance on State v. Wills, 244 Kan. 62, 765 P.2d 1114 (1988), which suggests that ambiguous plea agreements must be construed in favor of the defendant. While the plea negotiations here are indeed ambiguous in that it is unclear from the record whether the decision to reduce the sentence to one applicable to an E felony was part of the agreement itself, or simply a gratuitous act on the part of the prosecution, Wills does not answer the question presented. Even if we follow Wills and construe the agreement to be that the prosecution induced appellant's plea with the promise of an illegal sentence, the question remains as to what remedy should be available to appellant.
The State contends that the remedy chosen by the trial court, that of resentencing to the minimum sentence applicable to a D felony, is sufficient in that the State agreed to and did recommend probation, which was granted by the court. Appellant, on the other hand, claims he should be entitled to withdraw his plea.
Support for appellant's position is found in Chae v. People, 780 P.2d 481 (Colo. 1989), a case brought to our attention during oral argument by the attorney for the State. In that case a defendant who was convicted on his plea of guilty to second-degree sexual assault filed a motion to vacate his plea, claiming that his plea was not knowingly or voluntarily made because he had been unaware of the impact of certain aspects of the plea agreement. The Colorado Supreme Court determined that the original sentence handed down by the trial court was illegal and ultimately concluded that when a defendant enters into a plea agreement that includes as a material element a recommendation for an illegal sentence and the illegal sentence is in fact imposed on the defendant, the guilty plea is invalid and must be vacated because the basis on which the defendant entered the plea included the impermissible inducement of an illegal sentence. 780 P.2d at 486-87.
Construing the plea agreement as we do in favor of appellant, we find part of the inducement to be the promise of an illegal sentence. We conclude the logic of Chae is sound; thus, we find the trial court erred in failing to set aside the conviction and in failing to allow the appellant to withdraw his plea.
*453 Turning now to appellant's second issue, that of whether the trial court erred in failing to give an entrapment instruction, we find the law regarding instructions well stated in State v. Hunter, 241 Kan. 629, 740 P.2d 559 (1987):
"In a criminal action, a trial court must instruct the jury on the law applicable to the theories of all parties where there is supporting evidence.... When considering the refusal of a trial court to give a specific instruction, the evidence must be viewed by the appellate court in the light most favorable to the party requesting the instruction." 241 Kan. at 644.
"[A] defendant is entitled to an instruction on his or her theory of the case even though the evidence is slight and supported only by defendant's own testimony." 241 Kan. at 646.
The evidence in the record was sufficient to justify the giving of an instruction on entrapment. Both the appellant and the State's undercover agent testified that it was the agent who originally conceived the idea that appellant sell marijuana to her. In the second transaction, the agent once again asked appellant to sell marijuana to her. Appellant testified the only reason he sold marijuana to the State's agent was because she begged and pleaded with him to sell her marijuana. He testified that the sale was without profit to him and was done as an accommodation to a person he believed was to marry his friend Chopper. Though the State presented a notebook containing the appellant's handwritten notes referring to numerous prior drug transactions in an attempt to establish appellant's predisposition to sell drugs, appellant offered the explanation that the notes referred to drug transactions of a third person in which he was not involved, and that he only kept records for that person. It is not the function of this court to weigh the evidence or determine the credibility of the parties. Rather, we are to judge whether sufficient evidence existed in the record to justify giving the requested instruction. We believe the record contains such evidence and find that it was error on the part of the trial court to fail to give the instruction.
The judgment in case No. 84 CR 501 is reversed and the case is remanded to allow the appellant to withdraw his plea of guilty and for further proceedings consistent with such withdrawal.
The judgment in case No. 87 CR 128 is reversed and the case is remanded to give the defendant a new trial.
