added generation logic