attempted to finish peak detection but running into issues for arbitrary input