Yes, I think that is the right way to do it. I looked at the oracle version, and it is analogous to what you are proposing.
When debugging this, I must have caught up in making it work, and I forgot to go back and check that it still matched the oracle version in functionality.
Thanks for finding this Jun!