refactor if statement into trinaries