fixing logic for transaction