tm program flow works but not yet correct