Fixed the for loops in !ddg