Now that the function is factored out in a single place, we can refactor it to not use deprecated API.