Replaced ternary operators with if-statements to aid readability