refactoring switch sentence