refactor iterators with is_last