made script more robust/lenient