cleaning in the order of input file