make sandbox shell script more resilient