issue #3713: use reference in loop