Better way of getting the string from the buffer