refactored version of findpeaks appears to work