tidy the code
fix config KeyError