Fixed bug with unwanted popop and Window TypeError (hopefully)