modified to support infile list