edited the way the number of peaks is calculated