refacotring max_cell_heights