Added smoothing to peak detection