changed if else to a ternary operator