move k into thread private loop