recursion fix / refactor