Properly handle errors when the key is not found