Added ternary operator to make code more compact