[IMP]improve the code for popup window