fix the bug for sampling