move all the logic to background.js