abstraction of simple peak detection