# After Script in Subprogram the cobot stops for a second and continues

**URL:** <https://forum.universal-robots.com/t/after-script-in-subprogram-the-cobot-stops-for-a-second-and-continues/26190>\
**Category:** Technical Questions\
**Created:** [January 16, 2023, 10:28am UTC](https://forum.universal-robots.com/t/after-script-in-subprogram-the-cobot-stops-for-a-second-and-continues/26190 "2023-01-16T10:28:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon93969644](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@anon93969644](https://forum.universal-robots.com/u/anon93969644)\
**Post date:** [January 16, 2023, 10:28am UTC](https://forum.universal-robots.com/t/after-script-in-subprogram-the-cobot-stops-for-a-second-and-continues/26190/1 "2023-01-16T10:28:41Z")

</div>

As the title says I have a script in a subprogram but after that it just sits there for a second and goes further. While sanding this is not ideal for the cobot to stop at certain spots.

Is it the subprogram that does that or the script?

Here is the script:  
global move\_thread\_flag\_13=0  
thread move\_thread\_13():  
enter\_critical  
move\_thread\_flag\_13 = 1  
local towardsPos=calculate\_point\_to\_move\_towards(get\_forward\_kin(), [NewX,newY,0.0], var\_1)  
movel(towardsPos, a=1.2, v=0.025)  
move\_thread\_flag\_13 = 2  
exit\_critical  
end  
move\_thread\_flag\_13 = 0  
move\_thread\_han\_13 = run move\_thread\_13()  
while (True):  
sleep(1.0E-10)  
if (move\_thread\_flag\_13 \> 1):  
join move\_thread\_han\_13  
break  
end  
sync()  
end

its just the direction node in script and i made the distance variable. So i dont think thats the problem  
after the subprogram i also have a variable waypoint.
