fix wrong loop