fix bug in preprocess function