add default option to switch statement

and some code cleanup