more robust script