protecting view against errors resulting from no data

(also a little formatting change)