I don’t know, you’ll have to take a closer look at your code, but on the surface it seems that there are lots of nested loops, maybe that’s what’s taking so long, and if it finishes without errors then there’s probably something wrong in the logic. You can try printing more messages at some key places to check where the code is while it runs.