refactor background.js