fix template iteration