I'm not sure splitting this out to a separate function makes the code easier to follow.