My answer to this question was extremely similar to that of another user, but his idea is more streamlined and probably deserves to be marked the answer.
That said, our code is extremely similar, and I did post first.
The differences, in short:
- I had a little more contextual detail.
- His/her's was shorter and a thus cleaner, but the code was improperly formatted.
I fixed the code formatting. I had not yet read this or I would have deleted my answer at this point.
Shortly, the OP asked a question about implementation in a comment on and I attempted to add the necessary details in the other user's answer. My edit was rejected, so I added the details to my answer and left a comment for the OP.
Did I do the right thing and, if not, what should I do?