refactor back for switch