modify function to calcurate pane num