Still trying to solve to pop-up problem. Rewrote a little bit of code