fixed file overwrite issue and added downloading