Reformat the script so logging can be added