optimize sample