refactor config and db