modified generate script to avoid overwrite