You see a block of code inside a routine that has an obvious purpose & limited interaction with the rest of the code in the routine. Extract it as a helper routine. Name the routine after the purpose (not how the routine works).
The refactoring-aware among you will recognize "Extract Method" in this tidying.