modified exercise 2 to remove iterator