delivered the opinion of the court:
Defendant, Lawrence Salvaggio, pleaded guilty to the offenses of armed robbery, unlawful restraint, two counts of aggravated assault and a violation of bail bond. (Ill. Rev. Stat. 1971, ch. 38, pars. 18 — 2,10—3(a), 12 — 2(a)(1), and 32 — 10.) He was sentenced to the Illinois Department of Corrections for a term of not less than one and not more than three years for violation of bail bond, and to terms of not less than five and not more than nine years for each of the other offenses. The sentences were to run concurrently. On áppeal defendant contends that the trial court erred in failing to determine whether the guilty pleas were voluntary and in failing to determine whether he was fit to be sentenced. In addition, he contends that the sentences imposed for unlawful restraint and aggravated assault were excessive.
A review of the record shows that defendant was indicted for armed robbery, unlawful restraint and two counts of aggravated assault, and that he entered a plea of not guilty to these charges on November 29,1972. He was also indicted for violation of bail bond. On August 5,1974, defendant appeared before the trial court with his attorney who requested a *484conference with the trial judge and the State’s Attorney. The court explained to defendant what was likely to be discussed at the conference and that it might include a sentence recommendation. Defendant stated that he understood and that he had no objection to his attorney’s entering into such negotiations. The conference was held out of the presence of defendant and when the case reconvened in open court defense counsel informed the court that defendant wished to withdraw his pleas of not guilty and enter pleas of guilty to both indictments. Before accepting the guilty pleas the court explained to defendant the charges against him and the possible sentences, and further admonished him as to his constitutional rights with respect to trial by jury. After defendant signed jury waiver forms the following exchange occurred:
“The Court: You are doing this without any compulsion or threat or promises other than what you may understand your attorney and the State’s attorney have agreed to recommend should you plead guilty?
The Defendant: Yes.
The Court: They will be accepted. At this time do you wish to withdraw your plea of not guilty heretofore entered or do you wish to persist in your plea of guilty?
The Defendant: I want to withdraw my plea of not guilty.
The Court: How do you plead?
Mr. Gillman [defense counsel]: To each indictment your Honor, the defendant is pleading guilty.
The Court: And to each and every count of one indictment?
The Defendant: Yes.
The Corut: And to the other indictment which is a one count indictment, you plead guilty to all the charges before the court?
The Defendant: Yes.
The Court: Is this plea of guilty made voluntarily of your own free will without any promises, inducements, threats or anything other than your willingness to do that?
The Defendant: Yes.”
Thereafter, a factual basis for the guilty pleas was stipulated to and the court, having found that there was a sufficient factual basis for each of the pleas, accepted the guilty pleas and acknowledged that they were entered on the basis of negotiations. Defendant then waived a presentence report, but asked that sentencing be deferred for 30 days because of the impending death of his mother. The court granted the request and stated that at the sentencing hearing it would hear anything that defendant wished to present concerning the plea agreement and that defendant might be allowed to withdraw the guilty pleas if the court in good conscience could not thereafter impose the sentences agreed upon.
*485At the next hearing on October 4,1974, defense counsel indicated that defendant was under medication and might not understand the nature of the proceedings. Upon questioning by the court, defendant stated that he was there “to go to court,” and that although a sentence had been agreed upon he could not recall what it had been. The court then said:
“I think under the circumstances, unless either side objects to it, while I recognize that [defendant] is probably not as lucid and thinking as clearly as he normally could, I think that he has a general understanding of what is going on, and he does recall that there previously was a plea agreement. I am inclined to believe it would be proper for me to go ahead at this time under the circumstances.”
Both the State’s Attorney and defense counsel stated that they had no objection to proceeding. The court then asked defense counsel if he wished to state the terms of the plea agreement, and he replied:
“Your Honor, the plea agreement was a sentence of not less than five years nor more than nine years in the Department of Correction and it was my thought at the time and still is that this was a fair disposition of the case and I am yet in concurrence on it.”
He further stated that he had consulted at considerable length with defendant and that defendant fully understood and agreed to the plea agreement. The court then said:
“I think there is a question as to how much he understands. He did understand that he understood there was a plea agreement before. * * * I don’t think he is thinking clearly at this moment. * * * I asked the questions of the defendant. I think he has a general understanding but not as clear an understanding. I might say this, I think there might be a difference between what he would have to understand for me to take his guilty plea and what he would have to understand of the sentencing at this stage. In my opinion, he had clear understanding of the proceedings at the time of the arraignment in the plea of guilty.”
The following colloquy then took place:
“Mr. Gertie [State’s Attorney]: There is no question as far as fitness in the area of the behavior clinic.
Mr. Gilman [defense counsel]: No, I am not asking for one.
Mr. Gertie: His mother was buried, I can understand that, but I don’t think it becomes a legal problem.
The Court: I think it is a temporary circumstance.
Mr. Gertie: On that basis, I see no reason why we cannot proceed.
The Court: You are satisfied to proceed?
*486Mr. Gilman: Yes, I am, Judge.”
Defendant was then sentenced to a term of five to nine years on each of the charges of armed robbery, unlawful restraint, and aggravated assault, and to a term of one to three years for violation of bail bond, with aU sentences to run concurrently.
Defendant first contends that the trial court erred in accepting his guilty pleas without first stating the terms of the plea agreement in open court and without personally confirming the terms of the plea agreement with him. Supreme Court Rule 402 provides in part:
“In hearings on pleas of guilty, there must be substantial compliance with the following:
# # «
(b) Determining Whether the Plea is Voluntary. The court shall not accept a plea of guilty without first determining that the plea is voluntary. If the tendered plea is the result of a plea agreement, the agreement shall be stated in open court. The court, by questioning the defendant personally in open court, shall confirm the terms of the plea agreement, or that there is no agreement, and shall determine whether any force or threats or any promises, apart from a plea agreement, were used to obtain the plea.” Ill. Rev. Stat. 1973, ch. 110A, par. 402.
Rule 402 in general safeguards the rights of an accused by assuring that a guilty plea is intelligently, understanding^ and voluntarily made. However, we have held that whereas the objective of the rule is fixed, its application is flexible and does not require literal compliance. People v. Campbell (1973), 13 Ill. App. 3d 237, 300 N.E.2d 568.
Moreover, as stated by the Illinois Supreme Court Rule Committee in its Comments to Rule 402, one of the purposes of an open court statement and personal confirmation of the terms of a plea agreement is to prevent a defendant from swearing falsely at a later collateral attack upon the proceedings that the terms of the agreement reached were other than the actual sentence imposed. (50 Ill. 2d R. 402.) In addition, the Illinois Supreme Court has reasoned that giving visibility to the plea agreement will deter future unfounded claims by a defendant that an agreement entered was not honored. (People v. Dudley (1974), 58 Ill. 2d 57, 316 N.E.2d 773.) In Dudley, where the trial court failed to state or confirm the terms of the plea agreement in open court, it stated at pages 60 and 61:
“It does not follow, however, that the failure to comply with these provisions of Rule 402(b) must result in a reversal of the judgment of conviction. There is no claim that the plea of the defendant, who was represented by counsel, was not voluntary. There is no other claim of harm or prejudice to the defendant. When questioned by the judge the defendant expressed himself as *487being satisfied with the plea agreement which had been negotiated for him by his attorney, and even now there is no expression of dissatisfaction with the plea agreement’s terms. And finally, there is no contention by the defendant that the plea agreement was not honored — no claim that the sentence imposed was not the one agreed upon. What we observed in People v. Morehead, 45 Ill. 2d 326, 332, is appropriate here: ‘It is not the policy of this court to reverse a judgment of conviction merely because error was committed unless it appears that real justice has been denied
ft ft ft * ”
In the instant case defendant, in the presence of counsel, expressed a desire to withdraw his pleas of not guilty and enter pleas of guilty to all charges. Before accepting the pleas, the trial court informed defendant of the rights he was waiving and of the sentences that might be imposed. Defendant does not complain that his pleas were not voluntary. We further note that he has never expressed dissatisfaction with the terms of the plea agreement and does not now contend that it was not honored. In the absence of such allegations we fail to see how defendant was prejudiced by the failure of the trial court to strictly comply with Rule 402(b). Under these circumstances we conclude that the trial court’s failure to state the terms of the plea agreement in open court or to personally confirm its terms with defendant does not require reversal of the judgments of conviction.
However, we find merit in defendant’s further contention that the trial court erred in failing to determine whether he was fit to be sentenced after a bona fide doubt of his fitness was raised at the sentencing hearing held on October 4. Sentencing is a critical stage of criminal proceedings in which an accused has a constitutional right to counsel unless the latter has been effectively waived. (Mempa v. Rhay (1967), 389 U.S. 128, 19 L. Ed. 2d 336, 88 S. Ct. 254; People v. Hinkle (1971), 1 Ill. App. 3d 202, 272 N.E.2d 300.) The trial or sentencing of a person at a time when he is unfit is in violation of due process of law (People v. Burson (1957), 11 Ill. 2d 360, 143 N.E.2d 239), and is prohibited by statute. Section 5 — 2—1 of the Unified Code of Corrections (Ill. Rev. Stat. 1973, ch. 38, par. 1005 — 2—1) provides in pertinent part:
“(a) For the purposes of this Section a defendant is unfit to stand trial or be sentenced if, because of a mental or physical condition, he is unable:
(1) to understand the nature and purpose of the proceedings against him; or
(2) to assist in his defense.
(b) The question of the defendant’s fitness may be raised before trial or during trial. The question of the defendant’s fitness to be *488sentenced may be raised after judgment but before sentence. In either case the question of fitness may be raised by the State, the defendant or the court.
(c) When a bona fide doubt of the defendant’s fitness to stand trial or be sentenced is raised, the court shall order that a determination of that question be made before further proceedings.”
Although the statute clearly provides that the trial court shall order that a determination of defendant’s fitness be made before proceeding further, once a bona fide doubt of fitness is raised, the decision of whether or not a bona fide doubt has been raised in the first instance rests within the discretion of the trial court. (People v. Skorusa (1973), 55 Ill. 2d 577, 304 N.E.2d 630; People v. Stanhope (1969), 44 Ill. 2d 173, 254 N.E.2d 512.) Fitness in this sense requires an accused’s taking an active rather than simply a passive role in assisting in his defense. People v. Heral (1975), 25 Ill. App. 3d 806, 323 N.E.2d 138, aff'd on other grounds, 62 Ill. 2d 329, 342 N.E.2d 34.
It is abundantly clear from a review of the record in the instant case that a bona fide doubt of defendant’s fitness was raised at the sentencing hearing concerning his ability to assist in his defense. At the beginning of the hearing defense counsel informed the court that defendant was under medication and that there might be a question as to his understanding of the proceedings. When the court questioned defendant his responses were limited to only indicate that he was there to go to court, and that although he understood that he had previously agreed to a sentence he could not remember what it was. The court nevertheless found that he had a general understanding of the proceedings, and that although that understanding was not clear, the condition was temporary. That doubt was raised as to defendant’s ability to participate in the hearing, however, is demonstrated by the failure of any party to address him thereafter.
The trial court concluded that there was a difference between what defendant would have to understand to plead guilty and what he would have to understand in order to be sentenced. We do not agree with this conclusion and hold that the test of fitness must be the same whether defendant is pleading guilty or being sentenced. (See People v. Heral) The applicable standard as provided by statute is whether defendant is able to understand the ñatee and purpose of the proceedings against him and whether he is able to assist in his defense. (Ill. Rev. Stat. 1973, ch. 38, par. 1005 — 2—1.) Here, where the record shows it was questionable whether defendant was able to cooperate with his counsel in presenting evidence in mitigation or rebutting evidence in aggravation, a bona fide doubt was raised as to defendant’s fitness to be sentenced, and it was incumbent upon the trial court at that point to make *489a determination of fitness before proceeding further. It is therefore necessary to vacate the sentences imposed upon defendant and to remand the cause for resentencing and for such further proceedings as may be indicated or raised, if any, to determine his fitness to be sentenced.
Defendant further argues, the State concedes, and we agree that the sentences of not less than five years nor more than nine imposed for each offense of aggravated assault and unlawful restraint exceed the maximum permissible terms as set forth in the Unified Code of Corrections (Ill. Rev. Stat. 1973, ch. 38, par. 1001 — 1—1 et seq.). Aggravated assault is classified in the Criminal Code as a Class A misdemeanor (Ill. Rev. Stat. 1973, ch. 38, par. 12 — 2(b)), the sentence for which is any determinate term less than one year (Ill. Rev. Stat. 1973, ch. 38, par. 1005 — 8—3(a)(1)). Unlawful restraint is classified as a Class 4 felony (Ill. Rev. Stat. 1973, ch. 38, par. 10 — 3(b)), for which the statute provides an indeterminate sentence with a minimum term of one year and a maximum term not exceeding three years (Ill. Rev. Stat. 1973, ch. 38, pars. 1005 — 8—1(c)(5) and 1005 — 8—1(b)(5)).
For the foregoing reasons, the judgments of conviction are affirmed; the sentences imposed upon defendant are vacated and the cause is remanded to the circuit court of Cook County for such further proceedings as may be indicated or raised, if any, to determine defendant’s fitness to be sentenced, and for resentencing, not inconsistent with this opinion.
Affirmed in part, vacated in part and remanded with directions.
DEMPSEY and McGLOON, JJ., concur.