require_optional_folder common function