iterative solution for sample creation