fixing a bug where the popup would sometimes be broken until a page refresh