Fix the loop for dict