Updated script to get around permissions problems, and updated job to use master table