fixed key error handling