Adding new sampling code (untested).