Use a function for recursion