KeyError exception workaround