It's not easy to split the function without passing around a bunch of variables.  I've already had to pass `update_ips` 9 parameters to start with.  If I split it and end up passing these parameters around, or references to these parameters, to various deeper subroutines I think you'd end up even more lost!  I could add more comments to narrate what is happening, if that would help ... but what we're trying to do here is quite an involved and complicated task, so I'm not surprised the code is a bit complicated too.