refactor ternary