update generate button logic