Can you give an MRE?
Right now, I can’t run it with the code provided. If you provide an MRE, I can make suggestions from there.