rewrite transaction procedure