added generate script. Added indexing to read