added rejection sampling