refactor for transaction.