What i meant below is that this hunk should remain, potentially factored out to a separate function since you need to redo it on program change.