implementation of a peak detection filter