refactoring for more flexible config