Move count container creation out of main loop