fixed newPopup function