add peak detection to get dist and time threshold