revised for auto tuning