fix some random sampling functions