Thanks @daniel-nichter, this is exactly what i thought. Because i want to understand what exactly you didn't like in my version. So in future i'll not make many changes in my further PRs.
As you told, you asking us for working solutions and i think that solution was done and i also have test for my code. Yes, now i see some weak places in my version, but don't see really good reason to write your own solution from scratch.