refactor ternary out into a trait