changed if/else statement to ternary