updated version; output iteration fix