made more robust (had a situation where the script was started twice)