rewrite preprocessing script for labelling