Refactor redundant ternary if