Refactoring DB initialization