added click on popup
refactoring and swap checkbox
added javascript on popup