induction refactored, indexed recursion