small refactoring. switch case to if