fixed max Id issue + duplicate filenames