Added for loop to generate()

More progress on making generate() the key function