Initial version of the recursive code