fix KeyError exception