Port subsample function