refactor config code.