refactor config loading