Here you need to check the type returned by `MCresult -> getvalueref()` before you cast it as a string.
Also, `getvalueref()` is a getter: is returns a direct reference to the value stored, you don't want to release it as there is no copy of the value.