I'd like to say "thank you" to both of you once more.

I have been running the revised code and it has been working smoothly since then; however, I am still to analyze some larger set of data in the next dates to catch some edge cases (for now, it looks brilliant but I have been able to run it only on a couple of dozens of real-life examples). I will gladly update this thread in case of further inquiries.

P.S. I'll mark this thread as resolved in the next week (wanna give some time to myself to find edge cases, if any).