Added rejection sampling.