fixed potential iterator invalidation in logic_self()