Reverted old for do loop to use the for key, value loop