refactor switches