Bugfix loop index fixed