refactoring ternary