must call next() at the end