refactoring
bugfix for a exhausted iterator never throw NoSuchElementException.