recursion initial implementation