Fix errors that collections has been changed while foreach collections