Fixed nextWave() bug