Refactors explicit if-else statements to ternary