adaptive gain tuning