added functions to detect max and min, called Peaks