only unquote if ref is non-null