fixed invalidating of iterator in ranged for looop

Change-Id: Ib865ca3f2719c12a370a1a56d5e90b779e6b061a