cleaning up files before replacing them