buttonGenerate_Click method updated