moved code from popup.html to view