Restructured renderData function