Made code efficient in bckground.js

efficient