fix RuntimeError Set changed size during iteration