Welcome!
I’m afraid that it’s going to be very hard to answer your question from the information you’ve given. In particular, your example relies on a bunch of functions that we don’t have access to, and there’s probably a lot of complexity here that isn’t relevant to the problem. If you can remove all the extra complexity and boil the problem down to one thing, you’ll be much more likely to get a useful answer. For more info, please take a look at Please read: make it easier to help you