fix String class reference and use if instead of multiline ternary