Extract task for the first collector creation

There are many duplicated codes. I will reduce them.