optimization for task3