Pass number of tasks as a parameter.