change from switches to assertions, remove unnecessary code