Added nested loop