added additional KeyError exceptions handling