specifically the advice about an MWE? Your code is >300 lines, which is unlikely to be minimal and means you’ll find few people if anyone willing to debug this. Try and reduce your example to a few lines of code with dummy data which reproduces the error.