What do you mean by not working with the current data structures? I tested everything and it works as expected.

I tried your solution and it does not work.