Extract enum setup loop to setEnum function