refactor: simplify conditional assignment statements via ternary operator