add switchGen() func to APattern