; and (2) in the third sentence, by striking The agency and inserting the following: For units that are made available after preference is provided pursuant to the first sentence of this subparagraph, the agency . (d) Project-Based section 8 rental assistance Subparagraph (A) of section 8(d)(1) of the United States Housing Act of 1937 ( 42 U.S.C. 1437f(d)(1)(A) ) is amended— (1) by striking except that with respect and inserting the following: except that— (i) in the case of assisted dwelling units in a project assisted with project-based assistance under this section, the tenant selection criteria used by the owner shall give preference to otherwise eligible children who are in foster care, have attained an age such that the provision of foster care for such child will end by reason of the age of the child within 6 months, meet the requirements under clauses (i) and (ii) of paragraph (1) of the definition of at risk of homelessness in section 91.5 of the Secretary’s regulations (24 C.F.R. 91.5), as in effect on September 1, 2016, and have agreed to comply with the requirements under section 38(c); and (ii) with respect ; and (2) by inserting after preference is provided pursuant to clause (i) after to be assisted . (e) Terms and conditions on priority Title I of the United States Housing Act of 1937 ( 42 U.S.C. 1437 et seq.) is amended by adding at the end the following new section: 38. Terms and conditions on preference for assistance for children aging out of foster care (a) Preference For purposes of this section, the term preference for housing assistance means preference, for an otherwise eligible child in foster care, for— (1) occupancy in a public housing dwelling unit, pursuant to section 6(c)(4)(A)(i); (2) tenant-based assistance under section 8(o), pursuant to paragraph (6)(A)(i) of such section; (3) project-based assistance under section 8(o)(13), pursuant to subparagraph (J) of such section