Refined function of renderCells