extracted logic to panel controller