catching exceptions around keyerror crash