fix dict update in loop