Fixed a uncaught StopIteration