refactoring for UnitOfWork pattern