loop performance tweak