Fixed KeyError issue