Smoothing a value and check for extrems