No, it had nothing to do with my prowess as a young coder, but solely due to the fact that my predecessor did not know what a function was nor how to use parameters.
He had written unrolled versions of the same piece of code, with embedded SQL with minor variations in WHERE CLAUSE values which could be easily parameterized.
All I had to do after analyzing the code was move the code into a function and loop through it with different parameters values.
Such is life.