Neil, I hope you are doing well.
Here I posted the same question but with a code to understand in a better way what I really wany to my code to do and what it is doing actually.
Sadly I have not had luck trying to solve it. I hope you can understand the idea.