Dynamic task assignment in workflows