But I need to have it in a function and call it recursively.