tweak add_sample logic to avoid conditional in caching filter