changed if to ternary