Fix for stopiteration