just wrapped the whole cleaning in the `if (is_dir(`