patched for loop