fix keyerror