Properly handling the last step in the recursion