Added check for NaN in the setString method