clean up sampling code