Add the nested loop for Adam