Added sampling algorithm.