Moving name assignment out of task loop