Update logic in overwriting files