convert conditional into ternary syntax

Makes the code a bit more readable