fixed script to remove then append to master if exists