improve code block
remove unnessesarry palloc
improve tfn action by adding is_tfn_done