Set Assignee to all UserTasks of the process instance

I have a requirement where I need to set assignee’s to all the “user-tasks” in a process instance as soon as the instance is created, which is based on the candidate group set to the user-task.

i tries getting the user-tasks using this :

Collection<UserTask> userTasks = execution.getBpmnModelInstance().getModelElementsByType(UserTask.class);

which is correct in someway but i am not able to set the assignee’s , Also, looks like this would apply to the process itself and not the process instance.

secondly , I tried getting it from the taskQuery which gives me only the next task and not all the user-tasks inside a process.

Please help !!