popover if statement optimize