if/else refactoring