refactoring transaction