Refactor tertiary conditional assignment