switches refactor