Fixed the popup code to correctly utilize the update and close buttons