use dict.get(key, default) method to avoid KeyError.