Try to rewrite the streaming peak detection code

try to implement the true streaming peak detection function