Function to return recursive functions