Fix crashing bugs when there's no data

Can't we just return `'(no data)'` here isntead of assigning an array containing a string and later `join`ing it? Seems unnecessarily convoluted.