Updated generation logic