refactored config function