fixed a bug that increments the iterator even when offset is not zero.