Changed to the iterator function to save time & memory.