Fix count issue in console output.
Refactoring worker.js