refactor case distinctions