updating re-factored code to get number of tasks