Refactored to introduce add() and next() methods