Updated the nested dictionary code