modified to take variable number of input files