Key error fixing