minor fix in loops