Replaced alerts with popups; added promise