Yeah, that race condition is a little worrisome, but I have some ideas on how to deal with it safely. I'll try to prototype something generic with the event listener script that you can use here as well.