refactoring database component