read optgroups correctly