the recursive function works