draft working version of auto tuning