Why is this setting the value to itself if the ternary fails?