Avoid unnecessary recursion
Improve code documentation