Refactor config functions