refactor into a switch class