cleaning and subsampling