Maybe it's just me, but that doesn't seem that complicated, because each of those things is implemented at a different stage of the function, or is just a single line change.