changed set to transact which solves some subtle timing problems and is also more elegant