updated waveform selection algorithm