start of kernel resampling function