implement subsampling