refactoring bd