
74 P.3d 1064 (2003)
2003-NMSC-022
STATE of New Mexico and Tim Lemaster, Warden, Plaintiff-Appellants,
v.
Robert DAVIS, Defendant-Appellee.
No. 27,716.
Supreme Court of New Mexico.
May 28, 2003.
*1065 Patricia Madrid, Attorney General, Ralph E. Trujillo, Assistant Attorney General, Albuquerque, NM, for Appellants.
John Bigelow, Chief Public Defender, Jane Yee, Assistant Public Defender, Albuquerque, NM, for Appellee.

OPINION
CHÁVEZ, Justice.
{1} The State appeals directly to this Court from an order of the district court granting Petitioner Robert Davis' (Defendant) writ of habeas corpus. This Court has jurisdiction over appeals from the granting of writs of habeas corpus. See Rule 12-102(A)(3) NMRA 2003 (providing that such appeals shall be taken to this Court). On appeal, the State claims that the district court erred in holding that, under limited circumstances, NMSA 1978, § 31-18-21(A) (1977) allows for judicial discretion in sentencing inmates for crimes committed during incarceration. The trial court found the statutory language  "consecutive to the sentence being served"  to mean that the first sentence for a post-incarceration crime must be added to the end of the original sentence but trial judges may exercise discretion in determining whether to impose consecutive or concurrent sentences for subsequent crimes committed during incarceration. We reverse the trial court and hold that the Legislature removed all discretion from the trial court in determining whether to impose consecutive or concurrent sentences on inmates for felonies committed during incarceration, and as such all sentences for inmate committed crimes are to be consecutive to the total of all combined sentences.

FACTS AND PROCEDURAL BACKGROUND
{2} On June 12, 1981, Defendant was convicted of larceny and four counts of armed robbery in San Juan County and sentenced to thirteen years in prison. During this thirteen-year term of imprisonment, Defendant committed numerous crimes in different counties both as an escapee and while incarcerated. In 1982 he was convicted in Bernalillo County of various crimes including armed robbery, false imprisonment, and unlawful taking of a vehicle. He pled guilty to 33 counts and was sentenced to a nine-year term in prison. In 1984 he was convicted of possession of a deadly weapon by a prisoner and sentenced to a four-year term of imprisonment. In 1985 Defendant was convicted of the felonies of escape from the penitentiary, possession of a firearm by a felon, aggravated assault upon a peace officer, false imprisonment, and conspiracy for which he received a 17 ½ year sentence. Then, in 1988 Defendant was convicted in Bernalillo County of aggravated assault with a deadly weapon and sentenced to 6 ½ years in prison. Also, in 1988 Defendant was convicted in Santa Fe County of escape from the penitentiary and sentenced to thirteen years in prison.
{3} The six judgment and sentencing orders addressed in this opinion are labeled alphabetically for ease of reference and track the scheme developed by the trial court.
San Juan County, No. CR 81-88. Sentenced to 13 years in prison beginning on June 12, 1981.
Bernalillo County, Nos. 34739 and 34906. Sentenced to nine years on August 10, 1982, with the sentence to run "consecutive to the time the Defendant is presently serving in San Juan County Cause No. CR-81-88."
*1066 Torrance County, No. CR-82-44. Sentenced to four years on May 31, 1984, with the sentence "to run consecutive to the thirteen year sentence being served by the Defendant under San Juan County Criminal Cause No. 81-88."
Valencia County, No. VA-85-007-CR. Sentenced to a total of 17 ½ years on October 9, 1985, with the total sentence to run "consecutive to the sentences he is presently serving in the Department of Corrections in cause numbers 34739, and 34906, Bernalillo County, New Mexico and cause number CR-82-44, Torrance County, New Mexico."
Bernalillo County, No. CR. 42630. Sentenced to 6 ½ years on February 17, 1988, with the sentence "to run consecutive to the sentence the defendant is currently serving. Defendant is to receive credit for 925 days pre-sentence confinement and for post-sentence confinement until delivery to the place of incarceration."
Santa Fe County, No. SF 87-664 CR. Sentenced to 13 years on August 23, 1988. The Judgment, Sentence and Order of Commitment is silent regarding whether the sentence is to be consecutive or concurrent.
{4} The question raised by this appeal is whether the sentences were required to be stacked under Section 31-18-21(A) or whether, with the exception of Sentence B, the remaining sentences could run concurrently at the discretion of the sentencing judge. The Department of Corrections (Department) interpreted Section 31-18-2(A) to mandate the stacking of all sentences for crimes committed by Defendant while incarcerated. Defendant disagrees with the Department and argues that, with the exception of the 1982 sentence, the remaining sentences could run concurrently at the discretion of the sentencing judge. Under the Department's analysis Defendant must serve 63 years. Under Defendant's analysis, he should only be required to serve 39 ½ years. Neither analysis takes into consideration good-time credits.
{5} The trial court agreed with Defendant, granting his writ of habeas corpus and holding that the first conviction and sentence for a crime while Defendant was a prisoner had to run consecutive to the thirteen-year sentence Defendant was serving. However, the sentences after Defendant's first conviction could run either consecutive or concurrent depending on the discretion of the sentencing judge. The trial court held that Sentence B had to be served consecutive to Sentence A. As such, Defendant would have to serve the original thirteen-year sentence plus an additional nine years. However, since the sentencing judge in the Sentence C judgment specified that the sentence imposed on Defendant was to be served consecutive to Sentence A, the trial court held that Sentence C was to be served concurrent with Sentence B. Therefore, Defendant would not serve any additional time for his crimes in Torrance County. Again relying on the language in the sentencing judgment, the trial court held that since the sentencing judge in the Sentence D judgment specified that Sentence D was to be served consecutive to the sentences Defendant was serving in Bernalillo County cause numbers 34739 and 34906, and Torrance County cause number CR-82-44, Sentence D was to be served consecutive to Sentence B. Under this ruling Defendant's new sentence would be increased as follows: thirteen years under Sentence A, plus nine years under Sentence B, plus 17 ½ years under Sentence D  for a total of 39 ½ years. Because the sentencing judge in Sentence E specified that Sentence E was to be served consecutive to the sentence Defendant was serving at the time Sentence E was imposed, the trial court held that Sentence E was to be served consecutive to Sentence A and concurrent with the other sentences. Thus, Defendant would not serve any additional time for the Bernalillo County convictions in 1988. Finally, the trial court held that Sentence F was to run consecutive to Sentence A and concurrent with the other sentences because the sentencing judge was silent in Sentence F with regard to whether the sentence was to be concurrent or consecutive to the *1067 other sentences. Therefore, Defendant would not serve any additional time for the crimes he committed in Santa Fe County. Defendant was to serve a total of 39 ½ years under the trial court's ruling.

STATUTORY CONSTRUCTION
{6} The issue before this Court is the interpretation of Section 31-18-21(A). Statutory interpretation is an issue of law, which we review de novo. State v. Rowell, 121 N.M. 111, 114, 908 P.2d 1379, 1382 (1995). A trial court's power to sentence is derived exclusively from statute. State v. Martinez, 1998-NMSC-023, ¶ 12, 126 N.M. 39, 966 P.2d 747. The primary goal in interpreting a statute is to give effect to the Legislature's intent. Id. ¶ 8. We begin the search for legislative intent by looking "first to the words chosen by the Legislature and the plain meaning of the Legislature's language." Id.; accord State v. Cleve, 1999-NMSC-017, ¶ 8, 127 N.M. 240, 980 P.2d 23. The application of the plain meaning rule does not, however, end with a formalistic and mechanistic interpretation of statutory language. D'Avignon v. Graham, 113 N.M. 129, 131, 823 P.2d 929, 931 (Ct.App.1991). Under the plain meaning rule statutes are to be given effect as written without room for construction unless the language is doubtful, ambiguous, or an adherence to the literal use of the words would lead to injustice, absurdity or contradiction, in which case the statute is to be construed according to its obvious spirit or reason. See State ex rel. Helman v. Gallegos, 117 N.M. 346, 347-48, 871 P.2d 1352, 1353-54 (1994). The legislative history of the statute, including historical amendments, see In re Gabriel M., 2002-NMCA-047, ¶¶ 13-15, 132 N.M. 124, 45 P.3d 64, and whether it is part of a more comprehensive act, is instructive when searching for the spirit and reason the Legislature utilized in enacting the statute, State v. Ogden, 118 N.M. 234, 243, 880 P.2d 845, 854 (1994).
{7} We apply the above statutory construction principles to discern the legislative intent in enacting Section 31-18-21(A), which provides:
Whenever an inmate in a penal institution of this state or of any county therein is sentenced for committing any felony while he is an inmate, the sentence imposed shall be consecutive to the sentence being served, and his period of parole shall be that set according to the provisions of Section 31-21-10 NMSA 1978.
Here, it is undisputed that Sentences B through F were for felonies Defendant committed while he was incarcerated. The crux of the appeal concerns what the Legislature meant when it wrote that the sentence imposed on Defendant for crimes committed while incarcerated "shall be consecutive to the sentence being served." The trial court held that the plain meaning of "consecutive to the sentence being served" meant that the sentence imposed on Defendant for crimes Defendant committed while incarcerated was to be consecutive to the particular sentence he was serving at the time of sentencing. The matter would have been simple had Defendant only committed one crime while incarcerated because his sentence for that one crime would simply run consecutive to the sentence he was serving. However, while incarcerated Defendant committed multiple crimes at different times. Under these circumstances the trial court concluded that the language of Section 31-18-21(A) permits the sentencing court to exercise discretion in deciding whether the sentences for the multiple offenses committed at different times are to run consecutively or concurrently. We disagree with the trial court's analysis. Section 31-18-21(A) does not allow a sentencing judge any discretion regarding whether a sentence is to be served consecutively or concurrently. The Legislature's use of the word "shall" in Section 31-18-21(A) makes consecutive sentencing mandatory. See State v. Guerra, 2001-NMCA-031, ¶ 14, 130 N.M. 302, 24 P.3d 334 ("The word `shall' as used in a statute is generally construed to be mandatory.").
{8} The legislative history of Section 31-18-21(A) buttresses our conclusion that the Legislature did not want a sentencing court to exercise discretion in determining whether to impose consecutive or concurrent sentences on an inmate for crimes committed while incarcerated. In 1977 the Legislature passed the Criminal Sentencing Act and included *1068 what is now Section 31-18-21(A) as part of the Act.[1]See 1977 N.M. Laws, ch. 216, § 10. When the Legislature added Section 31-18-21(A) to the Criminal Sentencing Act, it modified NMSA 1953, § 40A-29-9 (1963), which stated:
Whenever an inmate in a penal institution of this state or of any county shall be sentenced for committing any crime while an inmate, such sentence imposed shall be consecutive to the sentence being served unless the court specifies otherwise. (Emphasis added).
The 1977 omission of the phrase "unless the court specifies otherwise" convinces us that the Legislature intended to remove discretion from the sentencing court.[2]
{9} The Legislature's intent to remove discretion is also demonstrated by a comparison of Section 31-18-21(A) and Section 31-18-21(B). Under subsection B the Legislature left intact the sentencing court's discretion regarding the sentencing of individuals who commit crimes while on parole. Section 31-18-21(B) provides:
Any person, who commits a crime while at large under a suspended or deferred sentence or probation or parole, and who is convicted and sentenced therefor, shall serve the sentence consecutive to the remainder of the term, including remaining parole time, under which he was released unless otherwise ordered by the court in sentencing for the new crime. (Emphasis added).
The Legislature distinguished between crimes committed by persons while they are in a penal institution versus crimes committed while they are outside of a penal institution on parole. State v. Irvin, 114 N.M. 597, 600, 844 P.2d 847, 850 (Ct.App.1992). In Irvin, the Court of Appeals held that a court may exercise judicial discretion in granting presentence confinement credit to a person on parole, but that it has no discretion with respect to a person who is incarcerated. Id.; see also State v. Facteau, 109 N.M. 748, 749, 790 P.2d 1029, 1030 (1990). Both Irvin and Facteau emphasize that Section 31-18-21(A) mandates that sentences for inmate-committed crimes must be imposed consecutively without any allowance for judicial discretion.
{10} Having concluded that sentencing courts do not have discretion, we next discuss what the Legislature meant by the words "sentence being served." Defendant, to support his argument that those words refer to Sentence A, relies on Deats v. State, 84 N.M. 405, 503 P.2d 1183 (Ct.App.1972). The State on the other hand invites us to rely on NMSA 1978, § 33-2-39 (1889), previously compiled as NMSA 1953, § 42-1-59 (1889), which provides that "[w]henever any convict shall have been committed under several convictions with separate sentences, they shall be construed as one continuous sentence for the full length of all the sentences combined." In Deats, the Court of Appeals while considering the defendant's eligibility for parole, addressed whether combining sentences under two separate commitments into one continuous sentence would nullify statutory provisions regarding parole. The Court of Appeals in Deats, 84 N.M. at 407, 503 P.2d at 1185, stated that Section 33-2-39 "is general in its effect and applies in considering eligibility for parole." The Court concluded that Section 33-2-39 meant that separate sentences under one commitment are to be treated as one continuous sentence, but that separate sentences under separate commitments are not to be treated as continuous. The Court of Appeals rejected Deats' argument that he was eligible for parole because a sentence he received in 1969 was to be considered a continuation of a 1967 sentence. The Court acknowledged that a literal reading of Section 33-2-39 seemed to require that the 1969 sentence be considered a continuation of the 1967 sentence, but instead, the Court ruled that unless Deats were paroled to serve another sentence, he had to complete his 1967 sentence before he began to serve his 1969 sentence. Deats, 84 N.M. at 407, 503 P.2d at 1185. Thus, while arguably the Court of *1069 Appeals extended its interpretation of Section 33-2-39 beyond parole considerations, we believe such an interpretation would be too broad. Accordingly, we limit the holding in Deats strictly to purposes of parole administration and apply the literal meaning of Section 33-2-39 to the sentencing of inmates convicted of committing crimes while incarcerated.
{11} Since the Legislature removed discretion from the sentencing court, the natural result of Defendant's argument is that Sentences B through F would have to be consecutive to Sentence A, in which case Sentences B through F would have to be concurrent sentences. Under this approach Defendant would avoid punishment for his crime sprees in Torrance, Bernalillo, and Santa Fe counties. This is because the 17 ½ year sentence in Valencia County was the longest sentence Defendant received for crimes committed while incarcerated. We question whether the Legislature could have intended to allow an inmate to commit numerous crimes with impunity and suffer no consequences. Indeed, we are persuaded that when the Legislature made Section 31-18-21(A) a part of the Criminal Sentencing Act, the Legislature intended sentencing courts to stack the sentences of inmates who were convicted of crimes while incarcerated.
{12} All of the provisions of a statute, together with other statutes in pari materia, must be read together to ascertain legislative intent. Quintana v. N.M. Dep't of Corr., 100 N.M. 224, 225, 668 P.2d 1101, 1102 (1983). The rule that statutes in pari materia should be construed together has the greatest probative force in the case of statutes relating to the same subject matter passed at the same session of the Legislature. 2B Norman J. Singer, Statutes and Statutory Construction § 51.03, at 237 (6th ed., rev.2000). The Criminal Sentencing Act made significant changes in the sentencing statutes of the Criminal Code. The changes included adding mandatory sentence enhancements for use of a firearm, see NMSA 1978, § 31-18-16 (1977, as amended through 1993), and for habitual offenders, see NMSA 1978, § 31-18-17 (1977, as amended through 2002). In requiring lengthier periods of incarceration and mandatory sentences, the legislative intent was to get tougher on crime in an effort to, among other things, reduce recidivism. Allison Grace Karslake & Kathleen Kennedy Townsend, Definite Sentencing in New Mexico: The 1977 Criminal Sentencing Act, 9 N.M. L.Rev. 131, 132-33 (1979). Construing Section 31-18-21(A) together with the other sentencing statutes in the Criminal Sentencing Act leaves us with the inescapable conclusion that the Legislature intended to impose harsher and more certain punishment on inmates who commit crimes while incarcerated. Thus, sentencing courts are required to stack sentences under Section 31-18-21(A).
{13} Adding support to our decision that "sentence being served" means the aggregate of the sentences imposed is United States v. Brown, 333 U.S. 18, 68 S.Ct. 376, 92 L.Ed. 442 (1948), where the U.S. Supreme Court interpreted a provision of the Federal Escape Act which at the time required a sentence for escape or attempted escape to begin upon the expiration of any sentence "under which such person is held at the time of such escape or attempt to escape." Id. at 22, 68 S.Ct. 376 (construing 18 U.S.C. § 753h (1940) (current version at 18 U.S.C. § 751 (2002))). The Court looked to legislative intent and determined that the Act contemplated additional punishment even though the language was not a "nicely precise" way of stating that the sentence for escape should begin upon the expiration of the aggregate of the terms of imprisonment imposed by earlier sentences. Id. at 25, 68 S.Ct. 376. The Court noted that the principles of strict statutory construction of penal statutes must not override common sense and the evident statutory purpose. Id. "No rule of construction necessitates our acceptance of an interpretation resulting in patently absurd consequences." Id. at 27, 68 S.Ct. 376. Likewise, this Court will not construe statutes in a manner contrary to the intent of the Legislature and in a manner that leads to absurd or unreasonable results. State v. Romero, 2002-NMCA-106, ¶ 8, 132 N.M. 745, 55 P.3d 441.
{14} Defendant invokes State v. Anaya, 1997-NMSC-010, ¶ 30, 123 N.M. 14, 933 P.2d 223, for the proposition that doubts *1070 about construction of criminal statutes are resolved in favor of lenity. The rule of lenity counsels that criminal statutes should be interpreted in a defendant's favor when insurmountable ambiguity persists regarding the intended scope of a criminal statute. Ogden, 118 N.M. at 242, 880 P.2d at 853. However, lenity is reserved "for those situations in which a reasonable doubt persists about a statute's intended scope even after resort to the language and structure, legislative history, and motivating policies of the statute." Id. (internal quotation marks and citation omitted.) Here, we are guided by legislative history and statutes in pari materia in determining what constitutes a continuous sentence. With aide of legislative history and Section 33-2-39 we interpret "sentence being served" to mean the aggregate time an inmate is serving. As such, the rule of lenity does not apply since no doubts about construction and no insurmountable ambiguity exist with respect to Section 31-18-21(A).
{15} Based on the principles of statutory construction  including the plain meaning rule and a review of legislative history  we find that Section 31-18-21(A) removed all discretion from the trial court in determining whether to impose consecutive or concurrent sentences on inmates for felonies committed during periods of incarceration. The phrase "sentence being served" means sentences in the aggregate, and, pursuant to statute, all sentences imposed upon Defendant must run consecutive to the total of his combined sentences.

CONCLUSION
{16} We reverse and remand to the trial court to enter judgment denying Defendant's writ of habeas corpus consistent with this opinion.
{17} IT IS SO ORDERED.
WE CONCUR: PETRA JIMENEZ MAES, Chief Justice, PAMELA B. MINZNER, PATRICIO M. SERNA, and RICHARD C. BOSSON, Justices.
NOTES
[1]  In 1977 the present Section 31-18-21(A) was codified as NMSA 1953, § 40A-29-34 (1977) which modified NMSA 1953 § 40A-29-9 (1963).
[2]  The sentencing court still has discretion with regard to the length of sentence it wants to impose, suspend, or defer consistent with applicable criminal statutes violated by an inmate.
