replaced all_tasks with index