fix problem when popup is reopened