
158 N.W.2d 854 (1968)
STATE of Minnesota, Respondent,
v.
Gary Thomas SEEBOLD, Appellant.
Nos. 39966, 40784.
Supreme Court of Minnesota.
May 10, 1968.
C. Paul Jones, Public Defender, Ronald J. Wolf, Minneapolis, for appellant.
Douglas M. Head, Atty. Gen., Gerard W. Snell, Acting Sol. Gen., St. Paul, William B. Randall, County Atty., Thomas Quayle, Asst. Co. Atty., St. Paul, for respondent.

OPINION
FRANK T. GALLAGHER, Justice.
This is an appeal from a judgment of conviction of first-degree robbery and from an order denying defendant's motion to permit withdrawal of his guilty plea.
The case arose out of a complaint dated October 16, 1962, filed in the municipal court of St. Paul, charging defendant with first-degree robbery allegedly committed on October 9, 1962. After waiver of the preliminary hearing, an information charging him with first-degree robbery was filed in the District Court of Ramsey County October 30, 1962. Prior to arraignment, and upon motion of the Ramsey County public defender, the court referred defendant to the probate court of Ramsey County for examination and hearing to determine whether he was mentally ill. On November 21, 1962, the probate court found him mentally ill. On December 14, 1962, the court again referred the matter to the probate *855 court for a determination relating to whether defendant was insane, an idiot, or an imbecile. On December 27, 1962, the probate court found defendant mentally ill, insane, and to have homicidal tendencies. Based on findings of the probate court and pursuant to Minn.St. 631.18, the district court committed the defendant to the State Security Hospital at St. Peter on January 2, 1963, with provision that when he recovered he was to be returned for trial in Ramsey County.
On July 7, 1964, after a confinement of about 18 months, St. Peter Hospital authorities (the consulting psychiatrist and the acting medical director) notified the Ramsey County attorney:
"It is the medical opinion of our medical staff that this man [defendant], at this time, shows no evidence whatsoever of mental illness. He is considered to be competent to stand trial [and] to understand the nature of the offense for which he is charged."
Defendant was thereafter returned to Ramsey County. The public defender was appointed to represent him, and on October 19, 1964, he entered a plea of not guilty to first-degree robbery. On November 3, 1964, his case came before Judge Graff of the Ramsey County District Court on a proposed change of plea, and defendant, represented by his court-appointed attorney, changed his plea to guilty. Thereafter a presentence interrogation was held. In the course of that examination, defendant was questioned by the court about his plea of guilty. He was reluctant to admit the facts of the offense, and Judge Graff vacated the guilty plea and continued the case until November 9, 1964. At that time, defendant again pled guilty, which plea was accepted by the court. A presentence examination was again held, at which time, according to the court's memorandum made a part of the order appealed from, there was no reluctance on the part of defendant to admit the facts pertaining to the offense. A presentence investigation was ordered, and the case was continued until December 8, 1964, for sentencing. At that time, defendant's attorney informed the court that he had had an opportunity to read the presentence investigation report of the probation officer and was fully aware of defendant's feelings and of the medical report that was submitted upon defendant's return from the hospital. He stated that he felt that defendant had gained something that was "at least very valuable" from his experience at the hospital and that he was better off and far better orientated and more understanding on December 8, 1964, than at any time in the past. He requested in behalf of defendant that if it would appear to the court that defendant might be incarcerated for a great period of time, the court take cognizance of the time defendant spent in St. Peter, and the provisions of the new code then applicable to the type of robbery involved.
The court then asked defendant whether he had anything to say, and he replied:
"Regardless of the decision made by this Court, I do know it will be the best one, and I'm real pleased with the way my case has been handled during the past two years, and I want to thank the judicial body for the way in which my problems have been handled."
The court then imposed sentence according to law but the maximum was limited to 15 years under Minn.St.1961, § 243.01.
Subsequently defendant appealed, and pursuant to State v. Clifford, 267 Minn. 554, 126 N.W.2d 258, we remanded the case to the district court for hearing on the motion to change the plea and vacate the judgment based on the following grounds: (1) That the plea was involuntary; (2) that defendant was not mentally capable to enter the plea; and (3) that he was inadequately represented by counsel.
At that hearing it appeared that defendant had his first mental illness in the form of a breakdown while in the United States Navy in 1959. He was unable to explain *856 accurately the nature of his mental condition at the time of the offense charged here. He thought that he had committed the offense because he had been sick for several years and had not been aware of it. Based on his treatment at St. Peter Hospital, he also thought that it might have been caused by a combination of drinking, financial problems, and marital troubles. Defendant claimed that he was frightened while in the St. Peter Hospital, apparently because of the treatment he received, and that because of this fright and the attitude of his court-appointed counsel, he changed his plea to guilty because he did not want to go back to the St. Peter institution. In reply to a question as to why he changed his plea from guilty to not guilty, defendant stated that he thought the authorities would return him to St. Peter if he did not change his plea. He also asserted that his court-appointed counsel talked him into the guilty plea and into admitting the elements of the crime at the sentencing hearing. However, he indicated inferentially that he told his brothers that he had a good defense.
The trial court stated in its memorandum:
"The suggestion is made that the plea of guilty entered on November 9, 1964, was involuntary. His testimony was that he had a great fear of being sent back to the Minnesota Security Hospital and this fear caused him, in part, to enter a plea of guilty. The fact of the matter is that on July 7, 1964, the officials of the Minnesota Security Hospital wrote a letter indicating that their medical opinion was that the defendant showed no evidence whatsoever of mental illness. The defendant knew this when he was returned to Ramsey County for trial. It is now suggested that there was a fear of being sent back to the Minnesota Security Hospital and this fear was a causative factor in entering a plea of guilty. The statement by the defendant in which he states that he is `real pleased with the way my case has been handled during the past two years' certainly is not indicative of any compulsion by anyone with respect to his plea. A careful reading of the entire proceedings completely satisfies me that there is no sufficient showing, or even a well founded suggestion, that the defendant was subject to any threats, promises or any coercive pressure.
"As stated in State v. Jones, 267 Minn. 421, 127 N.W.2d 153, pleas of guilty, which are confessions in open court, should be received with caution and no plea should be accepted where it appears doubtful that it is not made intelligently and understandingly. * * * There is no claim here, as I understand the defendant's position, that he is innocent. If I perceive what is attempted here by the defendant, it is to be permitted to withdraw his plea of guilty so that upon a trial he may assert the defense of insanity. A motion for the withdrawal of a plea of guilty is addressed to the sound discretion of the trial court. See State v. Waldron, 273 Minn. 57, 139 N.W.2d 785; State v. Roggenbuck, 271 Minn. 557, 136 N.W.2d 857; State v. Harding, 260 Minn. 464, 110 N.W.2d 463; and State v. Jones, 234 Minn. 438, 48 N.W.2d 662."
It is our opinion that under the record and the rules applicable here the trial court must be affirmed. The order from which the second appeal was taken involved a discretionary matter on the part of the trial judge, and we find no reversible abuse of his discretion.
We have considered the record with respect to the insanity aspect of defendant's appeal. It is quite clear that commencing in 1959, defendant had some mental problems over a prolonged period of time. During 1962, the year in which he allegedly committed the crime involved here, he was committed to the Hastings State Hospital for about 3 months early in January. Later that year he fired a gun over the counter in the Dairy Home Store, St. Paul, hitting some cans and other articles on the shelf; he entered a St. Paul home, threatened the *857 occupants, and fired a shotgun into the wall; at another home he held a gun at the head of a man who lived there and fired a shot at another man in the house, narrowly missing him. On October 8 he committed the crime involved here. The Ramsey County probate court found him mentally ill about 12 weeks after the crime was committed. All of those facts would indicate that he was in a serious mental condition during 1962.
It is our opinion that the real question here is whether defendant understood the nature and elements of the crime charged and the consequences of his guilty plea when he made it before sentence was imposed not whether he was insane on October 8, 1962, when he committed the crime for which he pled guilty. In that connection, he testified at the November 3 hearing as follows:
"* * * I had no forethought on it, any premeditation. I realize I robbed this place. The state of my mind I was in I believe was produced by alcohol * * *. * * * I'm not trying to divorce any responsibilities or shirk anything on this issue. I want to get it over with and decided to plead guilty to this. That's why I talked it over with [my attorney]."
When asked by the court as to whether he entered the tavern with the idea in mind of holding it up, defendant answered:
"I really can't tell you what I had in mind at that time. I know I was emotionally upset, quite disturbed. I think I had a lot of animosity towards everybody and society at that time through this heavy drinking. * * * I just feel it was an impulsive action on my part. I just didn't think about any armed robbery before I went in there, I suppose, until I got to the door."
At the November 9 hearing he was asked by the judge:
"THE COURT: Mr. Seebold, is there any question about the fact that when you committed this offense you had with you a loaded shot gun?
"A. That's true."
The record satisfies us that, although defendant may have been emotionally upset and disturbed at the time he committed the crime, and although he may have feared being sent back to the hospital when he entered his plea of guilty, it was made voluntarily; that he was mentally capable to enter the plea when he did; and that he was adequately represented by counsel. It is our opinion that through these entire proceedings defendant was accorded great consideration by the courts and other authorities involved and that he was justified in telling the court before sentence was imposed that he was pleased with the way his case was handled.
Affirmed.
