Fix bug when switch generation type

Fix bug when switch generation type