length(files)==0 replaced by isempty(files)