Factored out background task functions