better error-checking and use "if" instead of "switch" on a variable that only has one valid expected value currently.