Avoid `static' variable in loop