handle popover logic