fixed the wave index bug