Added checks to avoid re-creating reference files that already exist
Add more checks to avoid recreating existing files