fix the stopping program problem when KeyError occured