Adding diagnostics code to worker.js