Smarter enum generation algorithm