Catch StopIteration rather than everything