Refactored to use ternary operator