Adding check for existing file
Fixing issue with assigning new parent