fix in loop handling