Refactor in worker and related codes