put in sampling loop