refactoring unit of work