catch StopIteration exception