fix error from editing map during iteration