fix typo in opt_d var usage
remove switch (and replace by for/when where needed)