Avoiding KeyError accessing dict with .get