improved toEnum to handle list