fix logic of how to assign tasks to workers