fixed bug that popup window closes only on the first time