modified preprocessing part