Side effect in loop condition fix