Can we write this as if statements? Nested ternary operator is hard to read.