fixed and refactored config reader