fixed bug in TDL result references after calling subroutine