Chrome pop up cancel

Improved and refactored pop up code and implemented chrome pop up cancel somewhat