Add more robust python script