refactoring and db