Better way to set $tx - give it as argument to finalize()