refactor to ternary