; and (ii) shall terminate any contract or agreement described in clause (i) not later than the date that is 3 years after the date of the enactment of this Act. (B) Ownership and operation requirement Beginning on the date that is 3 years after the date of the enactment of this Act, any program or facility used for the activities described in subparagraph (A)(i) shall be owned and operated by a nonprofit organization or the Department. (3) Implementation plan Not later than 60 days after the date of the enactment of this Act, the Secretary shall develop, and make publicly available, a plan and timeline for the implementation of this subsection. 8. Appearance of detained aliens for other legal matters The Secretary shall establish rules to ensure that any alien detained in the custody of the Department who is required to appear in Federal or State court (including family court) for another matter is transported by an officer or employee of the Department to such court proceeding. 9. Procedures for detaining aliens (a) Probable cause and custody determination hearings Section 236 of the Immigration and Nationality Act ( 8 U.S.C. 1226 ) is amended to read as follows: 236. Apprehension and detention of aliens (a) Arrest, detention, and release (1) In general On a warrant issued by an immigration judge, or pursuant to section 287(a)(2), the Secretary of Homeland Security may arrest an alien, and in accordance with this section, detain the alien or release the alien on bond, subject to conditions, or recognizance, pending a decision on whether the alien is to be removed from the United States. (2) Exemption for unaccompanied alien children (A) In general This section shall not apply to unaccompanied alien children (as defined in section 462(g)(2) of the Homeland Security Act of 2002 ( 6 U.S.C. 279(g)(2) )). (B) Transfer of custody Any unaccompanied alien child in the custody of the Secretary of Homeland Security shall be transferred to the custody of the Secretary of Health and Human Services pursuant to section