Added a enumeration to keep track of the group an element belongs to.  This drastically cuts down on the string comparisions and improves readability