Complete recursive implementation