added sample generation function