refactor config loading into its own function