Fixed off-by-one error for last cell.