Added sampling for N times.