fix bug on order of tasks