Rewrote using iterator design