[Bugfix] properly increment index