Handles nil and non-string values