Will need to do this above the return statement in the error case for the first query exec, to avoid leaving stale contact ids in the temporary table