now with implementation for sampling on cluster