Added overwrite option logic