Recursion. It would make the code smaller, easier to understand, way easier to implement as well. What you are trying to do is one of the tasks recursion is very good at.
Glorfindel
- 1.1k
- 3
- 14
- 27