Here is an observation about writing software that may be so general as to be incomprehensible.
When you go from having one of a thing to having two of a thing, it is easier and possibly even more readable to just duplicate the thing instead of creating a generalized system that can handle N things.
Once you get to having three of a thing, it is better in all ways to simply have a generalized system that can handle N things.
But you don't *do* this when N reaches 3. You wait until N reaches 4
@mcc
So true.
That's why the good practice is to aisle anything you conceivable would repeat into a function and avoid global data like a plague.
If something makes sense in a loop, it is very likely to make sense in a function. Better now than tomorrow.