refactoring the worker to be able to handle multiple tasks