optimize sample count