¶ 1 On May 10, 1993, Adam M. pleaded no contest in children’s court to numerous delinquency charges including first degree murder, conspiracy to commit first degree murder, aggravated burglary, conspiracy to *506commit aggravated burglary, and larceny. The amended petition alleged that Adam M. committed these acts on February 7, 1993, eight days after his fourteenth birthday. The children’s court judge adjudicated Adam M. a delinquent child and transferred legal custody of Adam M. to the New Mexico Youth Authority (now the Children, Youth and Families Department) (Department) for an indeterminate period not exceeding two years. Upon the State’s motions, the children’s court extended Adam M.’s custody for a period of one year on April 7, 1995, and again on April 2,1996.
¶2 The State filed a motion for a third one-year extension of custody on March 11, 1997, after Adam M. had turned eighteen. The children’s court denied the motion, concluding that it no longer had jurisdiction to grant an extension under the statute in effect at the time of the delinquent acts because Adam M. had reached his eighteenth birthday. The State appeals the children’s court’s order, and we affirm.
¶ 3 At the time of the' offenses, the Children’s Code adopted in 1981 (1981 Code) was in effect. The legislature revised the Children’s Code in 1993 (1993 Code). This revision took effect July 1, 1993, after the offenses in question.
¶4 The State contends that the Children’s Code in force at the time of its requested extension applies to its motion rather than the 1981 Code, which was the law when Adam M. committed the delinquent acts. The 1993 Code allows for the extension of jurisdiction of the children’s court to age twenty-one, as discussed later in this opinion. The State argues this position based on the premise that under the Children’s Code, the court transfers legal custody of a delinquent child to the Department as opposed to sentencing the child as an adult. See NMSA 1978, § 32-1-34(E)(2) (1992) (current version at NMSA 1978, § 32A-2-19(B)(2)(b) (1996)) see generally Health & Social Servs. Dep’t v. Doe, 91 N.M. 675, 677, 579 P.2d 801, 803 (Ct.App.1978). Whereas an adult sentence is fixed, the disposition for a child remains open to modification or extension because the purpose of the transfer of legal custody of a delinquent child to the Department is to provide the necessary care and supervision so that the child can be rehabilitated. See NMSA 1978, § 32-1-38 (1992) (current version at NMSA 1978, § 32A-2-23 (1995); NMSA 1978, § 32A-2-24 (1993)); State v. Ricky G., 110 N.M. 646, 648, 798 P.2d 596, 598 (Ct.App.1990). Thus, the State asserts that a child adjudicated delinquent does not have an expectation regarding the future of his or her disposition or custody after the original children’s court’s disposition because the court may, at a later time, consider the best interests of the child and the safety of the community and grant an extension of custody. The State’s argument concludes that, as a consequence, the legislative enactments governing extensions in place at the time the extensions are granted or requested most accurately reflect the legislature’s intentions at that time and are not retroactive applications to the original disposition.
¶ 5 One of the express purposes of the Children’s Code is to provide supervision, care, and rehabilitation to a child adjudicated delinquent. NMSA 1978, § 32-1-2(B) (1989) (current version at NMSA 1978, § 32A-2-2(A) (1993)). The legislature has also declared its purpose to provide effective deterrence to acts of juvenile delinquency. Section 32-1-2(F) (current version at § 32A-2-2(B)). To fulfill these purposes under the 1993 Code, the children’s court may transfer legal custody of an adjudicated delinquent offender to the Department which, to supervise and rehabilitate the child, may place the child in a long-term commitment for up to two years in a long-term facility. Section 32A-2-19(B)(2)(b). The children’s court had similar alternatives under the 1981 Code. Sections 32-1-34(E)(2); -38(A).
¶ 6 The United States Supreme Court has considered the commitment of delinquent children to be “a deprivation of liberty ... incarceration against one’s will, whether it is called ‘criminal’ or ‘civil.’ ” In re Gault, 387 U.S. 1, 50, 87 S.Ct. 1428, 1455, 18 L.Ed.2d 527 (1967) (for purposes of privilege against self-incrimination). It has found “little to distinguish an adjudicatory [delinquency] hearing ... from a traditional criminal pros*507ecution. Breed v. Jones, 421 U.S. 519, 530, 95 S.Ct. 1779, 1786, 44 L.Ed.2d 346 (1975). The Supreme Court has held that such a restraint on liberty, even though in the context of a civil juvenile proceeding, invokes the essential elements of due process and fundamental fairness guaranteed by the Fifth and Fourteenth Amendments to the United States Constitution. See In re Gault, 387 U.S. at 30-31, 87 S.Ct. at 1445 (constitutional rights to notice, counsel, confrontation, cross-examination, appeal, and right against self-incrimination applicable to juveniles as it is to adults); In re Winship, 397 U.S. 358, 368, 90 S.Ct. 1068, 1075, 25 L.Ed.2d 368 (1970) . (due process safeguard of reasonable doubt standard applied to state delinquency adjudicatory proceeding); Breed, 421 U.S. at 527, 95 S.Ct. at 1784 (double jeopardy clause of Fifth Amendment applied through Fourteenth Amendment to state juvenile proceeding).
¶ 7 Article II, Section 19 of the New Mexico Constitution and Article I, Section 10 of the United States Constitution prohibit the New Mexico legislature from enacting ex post facto laws. State v. Norush, 97 N.M. 660, 661, 642 P.2d 1119, 1120 (Ct.App.1982). The ex post facto prohibition does not allow for a law that increases the punishment for an offense after the offense has been committed. See Lindsey v. Washington, 301 U.S. 397, 401, 57 S.Ct. 797, 799, 81 L.Ed. 1182 (1937); cf. State v. Hall, 119 N.M. 707, 709, 895 P.2d 229, 231 (Ct.App.1995) (due process clause prevents retroactive application of changed construction of a statute); State v. Alderette, 111 N.M. 297, 300, 804 P.2d 1116, 1119 (Ct.App.1990) (same).
¶ 8 One of the purposes of the ex post facto prohibition is to ensure that the accused individual receives fair notice of the crime and its punishment. See Weaver v. Graham, 450 U.S. 24, 30, 101 S.Ct. 960, 965, 67 L.Ed.2d 17 (1981). Adam M. argues that the ex post facto prohibition precludes the children’s court from applying the 1993 Code extension provisions for offenses which occurred under the 1981 Code, which was the law in effect at the time of the offenses. He states that such application of the 1993 legislation would place the constitutionality of his no-contest plea in question if he was not advised when he entered his plea that he could be confined until age twenty-one. We believe that his position is justified.
¶ 9 Adam M.’s plea was an integral part of the adjudicatory proceedings. See In re Gault, 387 U.S. at 36, 87 S.Ct. at 1448. Until he entered his no-eontest plea, Adam M. was entitled to a full adjudicatory hearing with the basic rights extended to him by the Children’s Code and the United States Constitution. To knowingly and voluntarily give up this right to an adjudicatory hearing, he must have knowledge of the potential penalties attached to the charged offenses. See Rule 5-303(E), NMRA 1997; State v. Lozano, 1996 NMCA 075, ¶ 18, 122 N.M. 120, 921 P.2d 316 (if defendant is not aware of material consequences of his or her plea, then defendant should be allowed to withdraw plea).
¶ 10 If we allowed subsequent legislation to enlarge the period of commitment, we would render undeterminable an essential ingredient of the plea decision. Notice, as guaranteed children in adjudicatory proceedings by Gault, 387 U.S. at 33, 87 S.Ct. at 1446, includes knowledge of all of the potential penalties associated with a crime charged. The question for a child confronting a plea would not be how many years of commitment would the child face, but whether the legislature might at some future time pass a law that would extend the commitment. Such uncertainty would make it difficult for Adam M., or any child facing an adjudicatory hearing, to make an informed plea decision. Applying the 1993 Code to permit an extension of Adam M.’s commitment for offenses which took place prior to the revision of the law would construe the 1993 Code in a manner precluded by the prohibition against ex post facto laws. See In re Appeal in Maricopa County Juvenile Action, 139 Ariz. 170, 677 P.2d 943, 946 (Ct. App.1984) (ex post facto laws apply to dispositions of delinquent children).
¶ 11 We are guided in our decision by analogous case law from another jurisdiction. In a nearly idential situation, the Washington Supreme Court reached the same result. See Johnson v. Morris, 87 Wash.2d 922, 557 *508P.2d 1299 (1976) (en banc). In that case, the juvenile was committed to a juvenile facility until age eighteen—the maximum commitment available at the time to the juvenile court. Id., 557 P.2d at 1301-02. The Washington legislature later expanded jurisdiction over juveniles to allow extension of commitments to age twenty-one. Id. at 1302. The court applied the ex post facto prohibition to a juvenile court proceeding and disallowed the extension of the child’s commitment past age eighteen. Id. at 1305. In the case on appeal, we agree with the children’s court that the ex post facto prohibition does not allow an extension of Adam M.’s commitment under the 1993 Code, and hence we must apply the 1981 Code to the State’s motion.
Interpretation of 1981 Code
¶ 12 The history of the Children’s Code provisions concerning extensions of commitments is pertinent to the State’s argument. In 1972, the legislature adopted the following provisions:
F. Prior to the expiration of a judgment transferring legal custody the court may extend the judgment for an additional period of one year if it finds that the extension is necessary to safeguard the welfare of the child or the public interest.
H. When a child reaches eighteen years of age all judgments affecting the child then in force automatically terminate, except that an agency to which the legal custody of an adjudicated delinquent child has been transferred for care and rehabilitation may request the court that made the original transfer of custody for authority to retain legal custody of the child for a period not to extend beyond the child’s twenty-first birthday. The request by the agency shall be made by filing a petition and the petition must be filed before the child’s eighteenth birthday____If the court finds on the basis of clear and convincing evidence, competent, material and relevant in nature, that the child is in need of further care and rehabilitation, it may extend the agency’s legal custody to a date not extending beyond the child’s twenty-first birthday.
1972 N.M.Laws, ch. 97, § 35.1
¶ 13 When the legislature revised the Children’s Code in 1981, it did not change Subsection F. However, it revised Subsection H to read: “When a child reaches eighteen years of age, all neglect and abuse orders affecting the child then in force automatically terminate.” 1981 N.M.Laws, ch. 36, § 29. That revision remained in effect until 1993. See NMSA 1978, § 32-1-38(H) (1992).
¶ 14 In 1993, after the offenses occurred in this case, the legislature made a substantial revision to the Children’s Code. It adopted a provision concerning extensions of long-term commitments reading:
D. Prior to the expiration of a long-term commitment, as provided for in Section 32[A]-2-19 NMSA 1978, the court may extend the judgment for additional periods of one year until the child reaches the age of twenty-one, if the court finds that the extension is necessary to safeguard the welfare of the child or the public interest.
F. Prior to the expiration of a judgment of probation, the court may extend the judgment for an additional period of one year until the child reaches the age of twenty-one, if it finds that the extension is necessary to protect the community or to safeguard the welfare of the child.
1993 N.M.Laws, ch. 77, § 52 (codified as amended at NMSA 1978, § 32A-2-23(D), (E) (1995)).
¶ 15 The judiciary’s responsibility when interpreting a statute is to carry out the intent of the legislature. See Cummings v. X-Ray Assocs., 1996 NMSC 035, ¶44, 121 N.M. 821, 918 P.2d 1321. In exercising this responsibility in this appeal, we begin by cautiously examining the plain language of the 1981 Code seeking to effectuate the objectives of the legislation. See id. ¶ 45; Key v. Chrysler Motors Corp., 1996 NMSC 038, *509121 N.M. 764, 768-70, 918 P.2d 350, 354-56; State ex rel. Helman v. Gallegos, 117 N.M. 346, 353, 871 P.2d 1352, 1359 (1994); State v. Henry L., 109 N.M. 792, 794, 791 P.2d 67, 69 (Ct.App.1990). We analyze the 1981 Code in its entirety and construe each part to achieve a harmonious result. Key, 1996 NMSC 038, 121 N.M. at 769, 918 P.2d at 355; Romero Excavation & Trucking, Inc. v. Bradley Constr., Inc., 1996 NMSC 010, ¶ 6, 121 N.M. 471, 913 P.2d 659. We review the children’s court’s interpretation of the Children’s Code, a question of law, de novo. State v. Rowell, 121 N.M. 111, 114, 908 P.2d 1379, 1381 (1995).
¶ 16 By its very nature, the 1981 Code (and its predecessors and successor) focused on children. See generally § 32-1-2 (current version at NMSA 1978, § 32A-1-3 (1993)). The legislative purpose with regard to delinquent children is to provide “a program of supervision, care and rehabilitation” for children consistent with the protection of the public interest. Section 32-1-2(B) (current version at § 32A-2-2(A)). A “child” is defined in all versions of the Children’s Code since 19722 as “an individual who is less than eighteen years old.” NMSA 1978, § 32A-1-4(B) (1995); NMSA 1978, § 32-1-3(A) (1992).
¶ 17 When we view the 1981 Code, as amended through 1992, in its entirety, we do not see any reference to extending a commitment for an adjudicated delinquent child after the child has reached eighteen. Section 32-1-38(F) provides no such authority. It permits the children’s court to extend a judgment transferring legal custody for additional periods of one year. It does not, as did its predecessors or does its successor, permit the court to order an extension until the child reaches the age of twenty-one. The plain language of the 1981 Code simply does not mention any age other than eighteen.
¶ 18 In the pre-1981 Code, Section 32-1-38(H) mandated the automatic termination of children's court judgments when a child turned eighteen, with one exception. It permitted extensions of legal custody of adjudicated delinquent children until age twenty-one and protected them from automatic termination at age eighteen. The legislature made substantial changes to that section in 1981. It eliminated all reference to the legal custody of adjudicated delinquent children and enacted language that spoke only to neglect and abuse orders which would automatically terminate when a child reaches eighteen years of age.
¶ 19 The State argues that when the legislature became silent concerning extensions of legal custody for children adjudicated delinquent who have reached age eighteen, it continued to intend to permit the children’s courts to extend custody as authorized by the earlier Children’s Code until such children reached twenty-one. The State asks us to read into the 1981 Code the language which the legislature deleted.
¶20 In making this argument, the State first contends that if the legislature intended to terminate all orders affecting children when they reach eighteen, the legislature could have expressly written such termination into Subsection H so that the plain language of the statute would indicate the legislative intent. We are unable to reach this conclusion. The legislative action in 1981 specifically removed express language which continued the children’s courts’ authority to extend commitment until age twenty-one. We cannot ignore this legislative action. If the legislature did not intend to change the law, why did it amend the language of Subsection H? The amendment entirely changed the subsection; it was not a stylistic change. We cannot assume that the legislature enacts useless statutes or amendments. Leyba v. Renger, 114 N.M. 686, 688, 845 P.2d 780, 782 (1992). Indeed, with such a substantial amendment, we must presume that the legislature intended to change the existing law. See In re Estate of Greig, 107 N.M. 227, 229, 755 P.2d 71, 73 (Ct.App.1988) (“When the legislature enacts a new law or amends an existing one, it does so for the express purpose of changing the law as it previously existed.”). Subsequent amendments to Section 32-1-38 in 1983, 1989, and *5101992 which did not alter the 1981 revision of Subsection H only underscore the legislative intent to change the law in 1981. See 1983 N.M.Laws ch. 243, § 4; 1989 N.M .Laws, ch. 328, § 8; 1992 N.M.Laws ch. 57, § 30. The children’s court correctly determined it did not have jurisdiction under the former Section 32-1-38(F) to grant an additional extension beyond Adam M.’s eighteenth birthday.
¶ 21 Nor can we accept the State’s position that the legislature committed a mere oversight with its 1981 Code and subsequent revisions which it then clarified years later under the 1993 Code. The courts “presume that the [legislature knows the law and acts rationally.” Bybee v. City of Albuquerque, 120 N.M. 17, 20, 896 P.2d 1164, 1167 (1995). We must assume that the legislature intended in 1981 to preclude extensions for juvenile offenders after they reached eighteen years of age and that the legislature reinstituted its previous policy allowing extensions to age twenty-one in 1993. See Alderette, 111 N.M. at 299, 804 P.2d at 1118 (presumption that legislature knows existing law and judicial pronouncements).
¶ 22 The State further argues that when the changes to Subsection H are read in conjunction with other sections of the 1981 Code, there is no intent “to lower all age limits to 18 or to deprive the children’s court of jurisdiction of anyone over 18.” Section 32-1-12(A) provided that children’s courts’ jurisdiction over a child automatically terminates when the child becomes an adult, “except that jurisdiction is retained until disposition of a case involving a child who becomes an adult during the pendency of the proceedings pursuant to the Children’s Code.” NMSA 1978, § 32-1-12(A) (1981). Rather than see a conflicting provision, we read this provision in correlation with Section 32-1-38. The word “disposition” was used in the 1981 Code to refer to the action taken at the adjudicatory hearing. The Section 32-1-12(A) exception applied when a child, under the age of eighteen by the Children’s Code definition, became an adult before the dispositional judgment in the proceeding. See NMSA 1978, §§ 32-1-33 (1972), -34(A); In re John Doe, 87 N.M. 172, 173, 531 P.2d 220, 221 (Ct.App.1975). In the ease on appeal, the child did not become an adult until after the children’s court made its disposition on May 10,1993.
¶23 We also read the automatic termination of all abuse and neglect orders at age eighteen to be consistent with the children’s court’s holding. The abuse and neglect provision of the 1981 Code applies to children in need of proper parental care. See NMSA 1978, § 32-1-3(L), (M) (1992) (definitions of “neglected child” and “abused child”) (current version at NMSA 1978, § 32A — L-2(B), (C) (1997)). A person reaching the age of majority no longer requires parental care.
¶24 We lastly address the State’s intimation that the legislature did not intend to amend Subsection H in 1981 to limit the age of a child when an extension of custody can be requested, thus leaving the age limit for extensions open-ended. Such an intent would permit a children’s court to extend custody of the Department for adults over age eighteen annually ad infinitum. But by their express purposes, the Department and its facilities are not designed for adults. See NMSA 1978, §§ 32A-2-4, -12 (1993). We do not adopt an interpretation of a statute that leads to absurd results. Chavez v. Mountain States Constructors, 1996 NMSC 070, ¶24, 122 N.M. 579, 929 P.2d 971; United Water N.M., Inc. v. New Mexico Pub. Util. Comm’n, 1996 NMSC 007, 121 N.M. 272, 276, 910 P.2d 906, 910; Alderette, 111 N.M. at 299, 804 P.2d at 1118.
¶25 In summary, we affirm the children’s court order that the children’s court lacked jurisdiction to extend the confinement of Adam M. beyond his eighteenth birthday. The Children’s Code in effect at the time of occurrence of the delinquent acts did not provide for jurisdiction past the age of eighteen. The children’s court is a court of limited jurisdiction, and “it is only permitted to do what is specifically authorized by the statute.” In re Angela R., 105 N.M. 133, 137, 729 P.2d 1387, 1391 (Ct.App.1986). The constitutional prohibition against ex post facto laws prevents us from applying subsequently *511adopted statutory provisions to confine Adam M. beyond his eighteenth birthday.
¶ 26 IT IS SO ORDERED.
BOSSON and ARMIJO, JJ., concur.