While I am sure the function you provided works as intended, I don't understand the logic behind it.
I'm still working from a pretty basic knowledge pool and rather than just using an example I want to understand it prior to using it.
Thanks for the advice, now I need to figure out exactly why that works.