updated with comments and also now uses TxResult