makes script more robust