Fixing a key error