wrong loop index