totally changed up structure of script and added pop-up functionality