added itertools efficient looping