make schedule script more error robust