move copy task out of function