refactor config detection