Replace ternary with if