Repeated code is planned to be factored out to improve clarity and readability. PiperOrigin-RevId: 259059978