refactor config code