; (2) by striking clause (i) and redesignating clauses (ii) and (iii) as clauses (i) and (ii), respectively; (3) in clause (ii) (as so redesignated by paragraph (2) of this section), by striking the semicolon and inserting a comma; and (4) by inserting after and below clause (ii) (as so redesignated) the following: except that, in the case of a child to whom this subparagraph applies solely because the child has been in foster care under the responsibility of the State for 24 consecutive months and is not in the care of kin (including fictive kin), the State may not file or join such a petition if a parent of the child is actively engaged in services to address the reasons the child entered care (including treatment for substance use disorder, mental health concerns, or parenting skills), if based principally on the incarceration of a parent, or if based principally on the detention of the parent by the Department of Homeland Security or the deportation of the parent; . 4. Expansion of purposes of Court Improvement Program (a) In general Section 438 of the Social Security Act ( 42 U.S.C. 629h ) is amended— (1) in subsection (a)(2)— (A) in the matter preceding subparagraph (A), by striking state and inserting State ; (B) in subparagraph (A)— (i) by inserting and their families before in a timely and complete manner ; and (ii) by striking , as set forth in the Adoption and Safe Families Act of 1997 ( Public Law 105–89 ), including the requirements in the Act related to concurrent planning ; (C) in subparagraph (B), by striking and at the end; (D) in subparagraph (C), by striking the period at the end and inserting ; and ; and (E) by adding at the end the following: (D) to increase access to high quality legal representation at all stages of a child welfare case for all parties to the case, including the children, the parents of the children, and, where applicable, kinship care providers and Indian tribes.