That will work just fine and dandy as near as I can tell.
GREAT! - understandable! (in terms of what it does).
For something like this I would probably add a comment in the code for others as tip to why this "understandable thing" was needed. Not just for the future readers, but you may even forget "why" after a few years. That stuff has happened to me before! If the technique is so tricky that you had to think a lot about it, put in a comment.