Added check for None in locations[k]['name']