Simplified result formatting code.