
344 So.2d 1189 (1977)
Harold BURNS
v.
STATE of Mississippi.
No. 50088.
Supreme Court of Mississippi.
April 20, 1977.
Michael J. Malouf, Jackson, for appellant.
A.F. Summer, Atty. Gen., by Karen Gilfoy, Asst. Atty. Gen., Jackson, for appellee.
Before PATTERSON, ROBERTSON and BROOM, JJ.
BROOM, Justice, for the Court:
By habeas corpus petition Burns (appellant) challenged the legality of his sentence and confinement which followed his plea of guilty to the sale of marijuana. Burns was charged under Miss. Code Ann. § 41-29-139(c)(2) (Supp. 1976). He appeals from the denial of his petition by the Copiah County Circuit Judge who then committed Burns to the Mississippi Department of Corrections rather than to the penitentiary. Burns' sentence is three years confinement and a $3,000 fine, which we affirm.
The state does not challenge habeas corpus as Burns' form of action here where he seeks post-conviction relief from his sentence upon a guilty plea entered on November 16, 1976. Next day he gave notice of appeal. Then on December 1, 1976, well within the time to perfect his appeal, he filed his Petition for Writ of Habeas Corpus which was heard and denied the same day. An order was entered leaving Burns' sentence unchanged except his commitment was then made to the Department of Corrections rather than to the penitentiary as ordered on November 16, 1976.
Nelson v. Tullos, 323 So.2d 539 (Miss. 1975), held that habeas corpus has the principal function of testing the legality of a petitioner's detention prior to conviction. We said in Nelson that habeas corpus as a post-conviction remedy may be used to release a petitioner from confinement only where his conviction rests upon an invalid statute, or was by a court lacking jurisdiction. See also, Keller v. Romero, 303 So.2d 481 (Miss. 1974); State v. Ridinger, 279 So.2d 618 (Miss. 1973). In the instant case, after the lower court entered its final order dated December 1, 1976, Burns gave a second notice of appeal to the court reporter *1190 (with copies to the district attorney and circuit clerk). As we said in Nelson v. Tullos, supra, "where a petition is filed seeking post-conviction relief the court should look through the form and to the substance of the petition." Burns' two notices of appeal were timely filed and his habeas corpus petition was filed prior to expiration of the time during which he could have perfected his appeal. Applying the rationale of Nelson, we will consider the matter as a regular appeal on the narrow issue of whether the sentence of Burns should have required his commitment to a state hospital rather than the penitentiary or Department of Corrections. It is arguable that we should not hear the matter because the Department of Corrections may in its discretion commit Burns to one of the hospitals rather than to prison, but we prefer to reach the heart of the question. Doing so will be productive of judicial economy, and will facilitate rather than frustrate the administration of justice. Generally, under Miss. Code Ann. § 99-35-101 (1972), appeals are not allowed "where the defendant enters a plea of guilty" and we do not deem the present case as an appeal from a guilty plea. Again, as in Nelson, our action here must not "be construed as an abrogation of the rule that habeas corpus does not lie as a general post-conviction remedy in Mississippi."
Burns contends that because he is under twenty-one years of age, Miss. Code Ann. § 41-29-150(c) (Supp. 1976) precludes his confinement except at one of two state hospitals. § 41-29-150(d) states:
Any person who has not reached his twenty-first (21st) birthday and who is convicted of a first offense under subsections (a), (b), or (c) of section 41-29-139, shall, or of a second or subsequent offense under subsections (d) or (e) of section 41-29-139, in the discretion of the court, may be confined under the terms set out in subsection (c) above for all or any portion of the sentence imposed.
Subsection (c), relied upon by Burns, provides that a juvenile first offender under age twenty-one shall be confined at East Mississippi State Hospital at Meridian, or Mississippi State Hospital at Whitfield, for the term of his sentence. This statute was interpreted by this Court in Worthy v. State, 308 So.2d 921 (Miss. 1975), to require sentencing of "juvenile first offenders" to one of the two state hospitals. Worthy does not hold that the indictment must charge a prior conviction in order to constitute basis of a sentence to confinement other than in a hospital. Language from earlier cases is cited in Worthy to the effect that "when there is substantial doubt as to which of the two (statutes) is to be applied," the statute providing lesser punishment is to be applied. Conflicting statutes or statutes ambiguous as to punishment are not involved in the instant case where Burns himself does not contend he is a "first offender"  thus Burns' case is the opposite of Worthy. The resolution of "substantial doubt" was applied favorably to Worthy because he was a true first offender. Davis v. State, 323 So.2d 741 (Miss. 1975), says that the holding in Worthy does not preclude the trial judge in sentencing juvenile first offenders from utilizing other legislative provisions which would promote his rehabilitation. In Davis we required the sentence to be changed to require confinement in a hospital rather than in the penitentiary, but there according to the record he was factually a first offender, which is not true of Burns here.
Burns admitted on questioning by the judge prior to sentencing that he had previously pleaded guilty to two other similar offenses (sale of marijuana). Clearly he was not a first offender but one who previously had been twice convicted of selling marijuana. § 41-29-139(c)(2), supra, sets the maximum penalty for sale of marijuana at twenty years imprisonment or $30,000 fine or both. Under § 41-29-150(c) the judge had the option at his discretion of sentencing Burns to confinement which may be in a state hospital or prison within the limits of § 41-29-139(c)(2).
Burns contends that Miss. Code Ann. § 41-29-147 (Supp. 1976), which provides increased (graduated) punishment for a *1191 second or subsequent offense, is pertinent here. His argument is without persuasion because the punishment here is within the limits of § 41-29-139(c)(2), which makes no mention of graduated or enhanced or increased punishment for repeated offenses as does § 41-29-147. Significant here is the fact that upon discovering Burns' prior convictions, the sentencing judge did not undertake to double his sentence under § 41-29-147. As noted by the judge below, it became evident at the sentencing of Burns that Burns had "committed the same offense on two prior occasions." The judge correctly stated that the prior convictions "causes him not to meet the qualifications ... as a person under the age of twenty-one who is convicted of a first offense... ."
Burns argues that under this Court's decision in Lay v. State, 310 So.2d 908 (Miss. 1975), in order for him to be sentenced as was done in this case, the indictment with particularity must state the prior conviction. In essence he says that his prior convictions cannot be considered by the sentencing judge unless the indictment charges the prior convictions. Applying the rationale of his argument to the facts, if the judge is unable to look outside the indictment for facts to help him decide upon an appropriate sentence, he could not consider Burns as under twenty-one because Burns' age is not mentioned in the indictment. Clearly judges need to know all available data about a defendant in order to determine judiciously the type sentence to be meted out. Prior convictions and age of a defendant about to be sentenced are two vital factors which judges universally consider regardless of whether such information appears on the face of the indictment. Obviously Burns confuses Lay with and fails to note its distinguishing features from his case. Lay dealt with a conviction under Miss. Code Ann. § 41-29-147 (1972), which provides enhanced punishment for a second or subsequent offense. Had the prosecution here desired to inflict enhanced punishment upon Burns, no doubt it would have so constructed the indictment. Viewed in its proper perspective, § 41-29-150(c), supra, rather than creating an enhancement of punishment situation creates an amelioration of punishment or alternative to confinement in prison. The practice of judges conducting pre-sentence inquiries and investigations so as to be aware of an accused person's past life is not new; we commend rather than discourage such procedures by all sentencing judges. Some concern arises here because the record does not reveal just what questions were asked Burns prior to his guilty plea. His brief states that he was interrogated about his past and in response told the judge "he had pled guilty to the charge of sale of marijuana" in both Rankin and Hinds Counties. In all future cases where a guilty plea and resulting sentence are in any manner attacked, the record should be caused to show what questions were asked and what information was given the accused about his rights prior to his guilty plea.
Burns was not indicted or sentenced under § 41-29-147 and his punishment was not based upon any statute providing enhanced or graduated penalties. The salient fact of this case is that Burns, not being a first offender, did not fall within the category of persons whom the legislature saw fit to require confined at a hospital rather than otherwise. Accordingly, Burns was eligible for punishment within the limits of § 41-29-139(c)(2), supra, and the sentencing judge meted out a sentence well below such limits. We reject the view that a judge in sentencing a person convicted of a crime must ignore prior convictions not referred to in the indictment. Lay is authority which directs sentencing judges as to how they should deal with an enhanced or graduated punishment statute, which is not an aspect of Burns' case. His arguments relate to conviction and penalties under § 41-29-147, supra, which provides for graduated or enhanced penalties not characteristic of the instant case. This is obvious when it is understood that Burns was sentenced under § 41-29-139(c)(2), which reads:
(2) Any other controlled substance classified in Schedules I, II or III, as set *1192 out in sections 41-29-113 to XX-XX-XXX, is guilty of a felony and upon conviction may be imprisoned for not more than twenty (20) years, or fined not more than thirty thousand dollars ($30,000.00), or both;
Careful reading of the above language shows that it merely provides limits of the penalty which may be imposed upon a defendant charged under said § 41-29-139(c)(2).
The original sentence imposed in this case directed Burns to be confined at the Mississippi State Penitentiary. In dealing with the habeas corpus petition, the judge corrected his order by committing Burns to the Mississippi Department of Corrections pursuant to Mississippi Code Ann. § 47-5-110 (Supp. 1976), which became effective July 1, 1976. No issue is raised or complaint made by Burns as to that aspect of the case.
AFFIRMED.
GILLESPIE, C.J., PATTERSON and INZER, P. JJ., and SMITH, ROBERTSON, WALKER and LEE, JJ., concur.
SUGG, J., took no part.
