I know it’s been some time, but I wanted to say that your solution looked fine, so I built that up into a function in a project I was working on to test it, and I can confirm your setup works as intended.
Hopefully someone else who stumbles upon this can use it, and isn’t turned off by others saying it isn’t working.