Using a generator instead of an interator; faster and cleaner.