reworked recursion