fix bugs in tool-sampling (experimental run)