WaveAlgorithm - tweaked, minor optimisation