This code should actually be part of the ApplySuccessfulProfile task, which you should change line 176 to create.