refactoring to ddd