Finds peak and valleys