Add loop feature

for loop feature for repeated optimization.