Rewrite to use the new iterator.

Change-Id: I2227cc7267cbc588006fbb1e7b58fc40e838055d