How would you optimize a script that cleans data and generates reports so it runs efficiently and handles errors gracefully at Advanced Micro Devices?