Refactor worker's code