added a method set_task_instances, because if task_instances changes then some methods need to be redefined