Added solution that uses ternary operator