version without main
with iterator