code cleanup for popup.html